I am building an educational tool that is used in classrooms. I manage a lot of information using sessions. However, I want the session to go away entirely when the user logs off. The next user who logs on should have a completely different session_id.
My log-out script looks like this:
<?php
session_start();
session_unset();
session_destroy();
session_regenerate_id();
header ("location: index.php");
?>
I tried it without session_start(), but it threw an error. So, I started adding stuff and ended up with the three lines you see.
I thought I had hit it with session_regenerate_id(), but that doesn't seem to do it. As a test, I created a page with this code:
<?php
session_start();
$old_sessionid = session_id();
session_regenerate_id();
$new_sessionid = session_id();
echo "Old Session: $old_sessionid<br />";
echo "New Session: $new_sessionid<br />";
?>
What I find, however, is that the "Old Session" is the same every time. In other words, as I refresh the page, I always get a different New Session, but the Old Session, the one that is live when I first hit the page, never changes.
Ideas?
Thanks.