Solved

User loin + session timeout very urgent

Posted on 2002-07-03
3
243 Views
Last Modified: 2008-03-17
hi,am new in php
i have php4.
i know how to deal with database in php and  a basic knowledge about sessions.
how can i set a timeout for a session so i can force the user to login again ?
0
Comment
Question by:selim007
  • 3
3 Comments
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7126896
Several things.

1 - Add the datetime to the session vars and check this BEFORE processing any other session vars when you get to a new page. If the difference between the current datetime and the session datetime is greater than some limit you decide upon, then they did nothing within the timeframe specified.

If the difference is LESS than the limit, then update the datetime in the session vars.

This means if the limit is 5 minutes and I update a page every 3 minutes, the last page still has a 5 minute limit.

2 - In the <HEAD></HEAD> of the page you can ...

<meta name="refresh" content="300;url=http://www.some.com/autologout.php">
<meta name="Cache-Control" name="no-cache,no-store">

or you can put them in using header();

Regards,

Richard.
0
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 200 total points
ID: 7126904
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");    // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
                                                     // always modified
header("Cache-Control: no-store, no-cache, must-revalidate");  // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");                          // HTTP/1.0

This is from the PHP manual.

0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7131648
Any luck?
0

Featured Post

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mysql between clause 2 25
PHP Sessions in WordPress 8 32
Insert won't work due to space in column name 5 22
Showing random records from database 10 37
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question