Solved

User loin + session timeout very urgent

Posted on 2002-07-03
3
221 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:RQuadling
Comment Utility
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:
RQuadling earned 200 total points
Comment Utility
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:RQuadling
Comment Utility
Any luck?
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now