|
Posted by Jason on 07/13/05 15:42
Well after a bit of tweaking of my script I realized it was not the code
that was causing the problem. It was a php.ini setting, I run a few
virtual hosts on my webserver and it turned out to be the
session.referer_check was set to 0, modify this to equal
session.referer_check = and it worked fine after a restart of the
webserver. Hope this helps someone else.
Jason wrote:
> I am having a problem with sessions. For some reason it keeps creating
> a new session for every page link you click and not using the original
> session created when session_start() gets called. Below is the code I
> am testing with.
>
> [one.php]
> <?php
>
> $SessionID = md5( uniqid( rand () ) );
>
> session_start();
>
> if( ( !session_is_registered( 'hash' ) ) || ( $_SESSION['hash'] !=
> $_SESSION['chkhash'] ) ) {
> session_name( 'prostarinventory' );
> session_register( 'hash' );
> session_register( 'chkhash' );
> session_register( 'count' );
> $_SESSION['hash'] = $SessionID;
> $_SESSION['chkhash'] = $SessionID;
> $_SESSION['count'] = 1;
> } else {
> $_SESSION['count']++;
> }
>
> print_r( $_SESSION );
>
> ?>
> [/one.php]
> [test1.php]
> <?PHP
> include 'one.php';
> print_r( $_SESSION );
> ?>
> <form action="test.php" method="post"><input name="test"
> type="text"><input name="" type="submit"></form>
> [/test1.php]
>
> [test.php]
> <?php
> include 'one.php';
> echo "SESSIONS: ";
> print_r( $_SESSION );
> echo "<BR>POSTS: ";
> print_r( $_POST );
> echo "<BR>GETS: ";
> print_r( $_GET );
> ?>
> [/test.php]
>
> Any help is appreciated, so far I have found that if I use the
> include_once 'one.php'; and simply refresh the page sessions work fine,
> but if you call the test1.php then submit the form the session variables
> aren't found in the old session and a new one is being created on the
> server.
>
--
Jason Gerfen
Student Computing
Marriott Library
801.585.9810
jason.gerfen@scl.utah.edu
"In my opinion anyone
interested in improving
themselves should not
rule out becoming pure
energy."
~Jack Handley,
The New Mexican, 1988.
Navigation:
[Reply to this message]
|