Session problems

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux