PHP, session problems
Im having problems with session variable after my database have changed the session variable, it doesnt update the ne开发者_开发问答w session variable when i press the back button but on database, it already updated but not on the webpage, i have to relogin to see the new variable.
and how do i use session_regenerate_id?
Copied from php.net:
<?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 />";
print_r($_SESSION);
?>
When a user presses the back button, their browser generally shows a cached page, rather than re-requesting the page, so that's most likely where your issue is coming from.
You use session_regenerate_id by calling it... and the user will be given a new session ID and their session will be transfered over to that ID, if you pass True
as a parameter, the session will be cleared, too. It's generally used to prevent session fixation attacks
Make sure that you have put below statement on top of your script otherwise no sessions will be handled:
session_start();
精彩评论