Link to home
Start Free TrialLog in
Avatar of world8
world8

asked on

php session expire/extend from html page using javascript/jQuery

Hi,

I'm looking to add session expire warning with two options to the user with "Ok" and "Extend" to all the html pages in my website, and this stays until the session expires or say, 5mins. I've done my website in php. Also, how do I set the session lifetime to say 15mins using php.

Regards
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of world8
world8

ASKER

Thanks for the comments.

why I want to do this is to provide better interface to the users.
Can you guys please give me the code? I understood when you said 'extend' through a simple ajax call, but I dont know how to extend the session, also I tried to set the session time to 5mins using the below

ini_set("session.gc_maxlifetime", 5 * 60); //5mins

but this doesn't look like working, I've set this after I validate the user.

Here is what I understood (but yet not sure how to create the code - php code / jQuery I know)
1. Set the session time to say 30mins, place a cookie on the server or create a variable and store it in th session (which stays until the session is expired). ... HOW DO I SET THE SESSION MAX TIME?
2. Run jQuery in the client side, after 25mins, give the warning to user to Extend the session... if he doesn't see this for 5mins, 30mins up push him to login page ... HOW DO I EXTEND THE SESSION, TO WHICH WE HAVE ALREADY SET THE MAXTIME?

I'm looking for the php code for the above two.
when we are in a session, every time we visit a page the session time counter starts from 0, is it the same case when we call ajax to a file on the server, if not why?