php - SESSION variables not passed from page after destroying the rest -
i @ total loss words.
i allow admin reset registration if reaching error during process. in theory, following code should function this:
page reached, $adminvalidated set based on session data. $_session array cleared; cookie cleared on consumer end; session id regnerated , session destroyed. session restarted , mentioned variable put session.
the "echo" statements included below work when redirect page (commented out below), session variables not carry over.
yes have started session on follow page well.
<?php session_start(); ob_start(); if( $_server['server_port'] == 80) { header('location:https://'.$_server['http_host'].$_server["request_uri"]); die(); } $adminvalidated = $_session['adminvalidated']; $_session = array(); if (ini_get("session.use_cookies")) { $params = session_get_cookie_params(); setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"] ); } session_regenerate_id(true); session_destroy(); session_start(); $_session['adminvalidated'] = $adminvalidated; echo $_session['adminvalidated']; /* header("location: ../a.php"); exit;*/ ?>
in general suffices call session_regenerate_id(true)
change session id of current session and invalidate association previous session id.
if additionally want clear session data except $_session['adminvalidated']
, this:
session_regenerate_id(true); $_session = array( 'adminvalidated' => $_session['adminvalidated'] );
Comments
Post a Comment