Solved

User loin + session timeout very urgent

Posted on 2002-07-03
3
260 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

737 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