Jump to content

Controlling going back to previous page after logout


Vidya_tr

Recommended Posts

Hi,

In my application I want to control going back to the previous page after logging out.

I have a problem when using session variables.

 

I am using javascript on the client side and php on the server side.

 

I tried using the the cache-control mechanism in html,but doesnt work for me.

I tried using session variables in php with session_register() and session_destroy();

But still I am not able to go ahead.

Anyone please help me with steps in using session variables.

 

I am new to php. So it is a bit difficult for me.Please help

 

Thanks..

 

 

Link to comment
Share on other sites

Start a Session.

<?php
session_start();
?>

Have each page that users are not allowed to visit require a vaild Session.

<?php
if($_SESSION['vaild']!==TRUE) {
    //redirect them to a different page or display nothing what ever you would like. and of course.
    exit();
}
// else Not needed
    /*You set the session as vaild and it has not been set as invalid as would happen on you logout code. Plus you should destroy the session, which would mean that variable would not be set and thus not TRUE.*/
?>

However as for the back, button even if you set no-cache browsers still store a lot of the data on the client side, but that does not mean they are able to do anything, the minute they try to fill in a form our take any other kind of action such as clicking a link that is protected by the session they will have to request information from the server and will be promptly denied as they do not have a vaild session.

Link to comment
Share on other sites

After logout, when I  click the GO FORWARD button of the browser it goes to next page.

I am able to perform some actions and update the database.But after that when I try to log out ,It shows a blank page .

 

Going to the next page by clicking the GO FORWARD button, once I logout ,should not happen as I am not logging in with the username and password.

 

Help me to prevent going to the next page by cliking browser button.

Link to comment
Share on other sites

Look, you need to validate the session prior to everything else! If you do not then yes, if you allow an update to the database prior to validation, then of course it will happen! Browser button or not, if you validate the session prior, no action will be taken.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.