php - $_SESSION variables and id do not carry over between pages on localhost -
i made simple sign page , when user's information validated, right before redirecting, session id changed according token system have set up. on register page, id correct on , have variable uid set manually. although problem on next page, id different, , variable undefined.
$_session['uid'] = $id; session_id($sessid); session_write_close(); header("location: /website/landing.php"); exit();
cookies enabled, sessions have directory "c:/xampp/tmp" , written to, see files correct id register page there. running on localhost , it's https connection. i've set way i'm told (through many other stackoverflow answers) should , , yet on next page:
<?php session_start(); echo session_id()."\n"; echo $_session['uid']; session_unset(); session_destroy(); ?> <!doctype html> <html> <head> <title>logged in</title> </head> <body> <h1>congratulations, have logged in!</h1> <a href="logout.php" title="">log out</a> </body> </html>
here when echo session id, it's new 1 , stays same everytime unless delete firefox settings, then, new 1 not user specific 1 wanted.
what cause of this? feel has redirection.
remove lines:
session_unset(); session_destroy();
as destroy session on every page load. causing new session.
i suggest reviewing docs session_destroy()
additional actions associated logout.
Comments
Post a Comment