Search code examples
phpsessionsessionidsession-storage

My session ID's stopped working


I have been working on writing a program and the session ID's have been working for several days. Now all of a sudden they are not working anymore. Any advice? The script codes are below for the test script I wrote to test passing the session ID's.

This is how I have the login page started, with no line breaks before this code.

<?php session_start();
?>
<!--HTML HEADER-->
<form action="sessionID.php" method="post">
name: <input name="stName" type="text" /><br/>
pass: <input name="newPass" type="text" /><br/>
<input name="" type="submit" value="submit"/>
</form>

It is passed through another page to test passing through a HREF link. Here is the top of that script.

<?php session_start();
$_SESSION['student']=$_POST['stName'];

Final page to echo the session ID.

<?php session_start();
$student = $_SESSION['student'];
echo session_id();

Anything I am doing wrong...?


Solution

  • When I redirected after verifying username password, I used http://www.domainname. I switched the redirect to http://domainname (no www.) and $_SESSION['user'] works perfect.