Session expiration help

Started on the old forum in December 2010 · view the original in the archive · old links redirect here

9 replies · 742 views · started 15 years ago · 1 min read

5 participants
adex3g Developer · 181 posts #1

Please i want you guys to help me with session. I want member session to expire if a member is idle for 10 minutes, but if not idle session should continue. This my ses from logme.php code: $user=$_GET['user']; $_SESSION['ses']=$user $timeout=time()+7200; $_SESSION['sesexpire']=$timeout; then my home.php $user=$_SESSION['ses']; if(!isset($user)) { echo "you are not login or you idle for 10minutes before. Pls relogin"; } else if(isset($user)){ /* i want my idle time to be 10m and member ses to automatically expire if the user idle for 10ms but if the member is not idle, he/she session should not expire. But i dont know how to do this, i want you people to help me out. Thanks */ } else{ my site code here }

have connected with http://adexchat.com ? Fun up with http://forum.adexchat.com

ori Lead · 512 posts #2

try this u will have to edit for ur session data

 
setcookie("phpsessid",$_COOKIE['phpsessid'],strtotime("+10 minutes"),"/");
firemax Developer · 221 posts #3

ori wrote: try this u will have to edit for ur session data

 
setcookie("phpsessid",$_COOKIE['phpsessid'],strtotime("+10 minutes"),"/");

if not works. you can use

setcookie(session_name(), $_COOKIE[session_name()], time() + 600, "/");

😉 or, use simply

ini_set("session.gc_maxlifetime", 10*60);

External image (may be gone) Free Mobile Web Scripts by me: Free Youtube Downloader, Tweets Reader, Facebook Wall Posts Reader PHP Tutorials: [How to Secure Your PHP Script (PHP SECURITY)](http://coding-talk.com/f14/how-to-secure-you…

adex3g Developer · 181 posts #4

Thanks ori and firemax, i am on mobile version so i cant click tns button. But i still not understand you guys. It is like this? if(!isset($_SESSION)){ print 'lol no session or idle time xpire'; } else if(isset($_SESSION)){ setcookie(sesssion_name(),$_COOKIE[session_name()],time()+600"/"); echo " hay! you are lazy to click for 10ms. And you session has expire, so you need to login again"; } esle{ site code here lol }

have connected with http://adexchat.com ? Fun up with http://forum.adexchat.com

Wintch Developer · 68 posts #5

Exuse. Wherd d0 we place dis code, login.php?

ori Lead · 512 posts #6

you use the code where session is created or use it to update expire time

firemax Developer · 221 posts #7

adex3g wrote: Thanks ori and firemax, i am on mobile version so i cant click tns button. But i still not understand you guys. It is like this? if(!isset($_SESSION)){ print 'lol no session or idle time xpire'; } else if(isset($_SESSION)){ setcookie(sesssion_name(),$_COOKIE[session_name()],time()+600"/"); echo " hay! you are lazy to click for 10ms. And you session has expire, so you need to login again"; } esle{ site code here lol }

//logme.php

$user=$_GET['user'];
$_SESSION['ses']=$user;
$timeout=time()+600;
$_SESSION['sesexpire']=$timeout;

//home.php

$user=$_SESSION['ses'];
if(!isset($user) || ($_SESSION['sesexpire'] < time()))
{
	session_destroy();	
	echo "you are not login or you idle for 10minutes before. Pls relogin";
}
else{
	$timeout=time()+600;
	$_SESSION['sesexpire']=$timeout;
	//your site code here
}

External image (may be gone) Free Mobile Web Scripts by me: Free Youtube Downloader, Tweets Reader, Facebook Wall Posts Reader PHP Tutorials: [How to Secure Your PHP Script (PHP SECURITY)](http://coding-talk.com/f14/how-to-secure-you…

ori Lead · 512 posts #9

$_SESSION['username'] = $_POST['username']; $_SESSION['password'] = $_POST['password'];

leadiztah Developer · 55 posts #10

U need to update always the time, in every php file you are g0ing to click.. I used cp n0w for br0wsing hehe, i cant p0st d c0de right n0w

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close