I'm really perplexed here. I'm starting a session on one page, checking username/password and redirecting to another page using GET. I'm putting the session id into the GET URl.
I removed most of the MySQL code in order to focus on the session issue.
<?php
session_start();
$id = session_id('PHPSESSID');
if ($qres[0] == $thepass && (strcmp($qres[0],$thepass)==0))
{
session_write_close();
header ("Location: test.php?id=$id");
}
?>
On the test page the id in the URL doesn't match the session cookie. I'm using a similar method on another site with positive results, hosted on the same server.
<?php
session_start();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?php
echo $_GET['id'];
echo "=======";
echo $_COOKIE['PHPSESSID'];
?>
</body>
</html>
The previous code produces the following results.
ecd5710b3bf978450f8ec1ba87e89ec3=======
Notice: Undefined index: PHPSESSID in test.php on line 15
The cookie is there but somehow undefined. Now if I put phpinfo(); on the line after session_start(); then the cookie id and GET id match.
I've done this before with success and can't figure this one out. Thanks in advance for any help.