hai
iam new to this domain. iam developing online quiz contest project in php (mysql,javascript,ajax) i need Automatic session timeout/logout and also i need time counter display using php and AJAX. pls refer any website. i searching for last 2 days..

advance thanks..

Recommended Answers

All 2 Replies

As per the first part of the question which is setting how long until the session expires or time-outs you can use the following code to adjust when it time outs. The first setcookie function will adjust it to a specified time (1 year) and the second set cookie function will set it to infinite time or whenever the browser is closed.

$second_till_timeout=60*60*24*365; //one year
setcookie ('PHPSESSID',$_COOKIE['PHPSESSID'],time()+$seconds_till_timeout); //until specified

setcookie ('PHPSESSID',$_COOKIE['PHPSESSID'],2147483647); //forever

And yes the php session does make a cookie called PHPSESSID which is what makes the session ends and this is what we are adjusting.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.