Session problems

From: Date: Tue, 12 Jul 2005 13:54:53 +0000
Subject: Session problems
Groups: php.general 
Request: Send a blank email to php-general+get-218541@lists.php.net to get a copy of this message
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 G. "In my opinion anyone interested in improving themselves should not rule out becoming pure energy." ~Jack Handley, The New Mexican, 1988.

« previous php.general (#218541) next »