Hi,

I have the LOGIN page, with the username and the password. By logging in, the users can view their information and they can submit their jobs. When the user click LOGOUT link, the page moves to main INDEX PAGE(i.e LOGIN page). The problem is it, when the user click the back button in the browser, again, the user continue in doing, submitting their jobs. I wants to stop this. When the user click the back button, the "error message should come login expired". Please give me a piece of script. How can i acheive this ? Thanks in advance...

Recommended Answers

All 3 Replies

Reset the cookie to an invalid value.

Hi,

Please see this code. This is how, i am setting my cookie. I am using Frameset.


index page

$kid = time;
$cookie = cookie(-name=>'logtime',
        -value=>$kid,
        -expires=>'+2m',
        -path=>'/cgi-bin/');


 print header(-cookie=>$cookie);
[B]print "<a href=/cgi-bin/auth/ssesschk.cgi?sid=0&rollno=$prollno target=\"_top\" >Logout</a>";

ssesschk.cgi -->logout page[/B]

my ssesschk.cgi coding

#!c:/perl/bin/perl
use CGI qw(:all);
$psid=param('sid');
$prollno=param('rollno');

if ($psid == 0)
{
use DBI;
my $dbh = DBI->connect("DBI:ODBC:xxxxx","dsn","pass") or die "Can not connect: $DBI::errstr\n"; 
$sth = $dbh->prepare("update tbname set kid = ? where rollno = ?") or die "Can not prepare SQL statement: $DBI::errstr\n"; 
$sth->execute(0,$pdeptcode) or die "Can not execute SQL statement: $DBI::errstr\n"; 
print <<EOF;
Content-Type: text/html

<html><head><title>Login</title>
<script>top.window.location.href="/index.html";</script>
</html>
EOF
}

When i click log out, i moves to index.html page. When the user clicks back button of the browser, they are continuing in doing their jobs. I want to stop this.
How i can check the cookie value and then how i can reset my cookie value. what is the use of in resetting the cookie value. Thanks in advance

You need to check the validity of the cookie at the beginning of each page. Then when the back button is hit, the cookie is checked and the user should get redirected to a logged out page. I am not familiar with the tools you are using, but the basics of state management through cookies would be to check the validity of the cookie at the start of each page and when the user logs out, reset the cookie to something that will not pass the test.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.