Page 1 of 1

can expired Session be restored?

Posted: Tue Apr 01, 2008 2:22 am
by eskio
Hi,
I have the following code to logout.

Code: Select all

if (isset($_POST["logout"])) {  // logout button is clicked
    // destroy session session
    unset($_SESSION['id']);
    unset($_SESSION['name']);
    session_destroy();
    
    // destroy cookies
    $sessionPath = session_get_cookie_params(); 
    setcookie(session_name(), "", 0, $sessionPath["path"], $sessionPath["domain"]); 
    header('Location: http://localhost/myfolder/login.php');
} // if (isset($_POST["logout"]))
It is working correctly BUT when I click the "Go Back" button (one or many times) on the browser, I have the following message:
"the page you are trying to view contains POSTDATA taht has expired from cache. If you resend the data, any action the form carried out will be repeated. To resend the data, click OK. Otherwise, click Cancel. "
and when I click OK, it displays the home page which should be displayed after the login page. That means the browser restores an expired session.

Please help me.

Re: can expired Session be restored?

Posted: Tue Apr 01, 2008 2:46 am
by s.dot
Is any code being ran after your header() call? Put exit; after it.

Re: can expired Session be restored?

Posted: Tue Apr 01, 2008 2:47 am
by EverLearning
eskio wrote:"the page you are trying to view contains POSTDATA taht has expired from cache. If you resend the data, any action the form carried out will be repeated. To resend the data, click OK. Otherwise, click Cancel. "
I'm guesing that the form this message was talking about was the login form, and since you clicked OK, it logged you in again. To avoid that, after logon redirect user to a page

Code: Select all

header("Location: $homeUrl"); // page you show after logon
exit();
That way, when you logout, and go back in the browser, you won't be loged in again.

Re: can expired Session be restored?

Posted: Tue Apr 01, 2008 7:48 am
by eskio
EverLearning wrote:
eskio wrote:"the page you are trying to view contains POSTDATA taht has expired from cache. If you resend the data, any action the form carried out will be repeated. To resend the data, click OK. Otherwise, click Cancel. "
I'm guesing that the form this message was talking about was the login form, and since you clicked OK, it logged you in again. To avoid that, after logon redirect user to a page

Code: Select all

header("Location: $homeUrl"); // page you show after logon
exit();
That way, when you logout, and go back in the browser, you won't be loged in again.

Thanks.

Re: can expired Session be restored?

Posted: Fri Apr 04, 2008 5:55 am
by anto91
Btw i dont belive localhost works when your project is on a extern server and not your devel pc

Edit: refering to your header('location: http://localhost*');