?
Solved

how to expire the PHP session after some predefined time

Posted on 2005-03-01
6
Medium Priority
?
249 Views
Last Modified: 2006-11-17
Hi friends,
This is very simple question
I want to expirer the session for the web page if user has not fill the data or take any action on the web page for the more than 1 minute .so can u tell me how i will do this
I know u  can unset or destroy the session variables by using session unset function but Here I want to unset the values at run time and that to be only if user has not taken any action on web page for 1 min  so plz tell how i will do the same using PHP  
thanks in advance
0
Comment
Question by:vvs
[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
  • 2
  • 2
6 Comments
 
LVL 6

Accepted Solution

by:
ThomasFranke earned 100 total points
ID: 13437174
You can use unset()  to unset a variable.

unset($_SESSION['UserValue']);    // unsets the session variable 'UserValue'

see http://www.php.net/manual/en/function.unset.php for more information on unset.

It might be a good idea not to rely on session expiration etc.
You could store the time of the last user request within the users session. Then
evaluate the time difference between the last request and the current one. If
the dime difference is greater than 60 secs display an approbiate error message.

0
 
LVL 2

Assisted Solution

by:DBB
DBB earned 100 total points
ID: 13443467
Hi,


Check out this tutorial, it explains step by step and includes code:-

http://www.phpfreaks.com/tutorials/77/0.php

Dbb
0
 
LVL 6

Expert Comment

by:ThomasFranke
ID: 13646216
Agreed.
0
 
LVL 2

Expert Comment

by:DBB
ID: 13647564
Also agreed.
0

Featured Post

Tutorial: Introduction to Managing a Linux Server

In this tutorial on systemd, we will explore:
-OS/Distro Adoption
-chkconfig and Other Legacy Commands
-Summary and Key Commands

Question has a verified solution.

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

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses

764 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