theinfamousmielie Posted March 24, 2009 Share Posted March 24, 2009 Hi all, This may be a very very stupid question I have an AJAX-based site going, with one page refresh, and naturally I use sessions. But the problem is that after x amount of time, the session expires. Which is good, except that on an AJAX based site I can't 'keep the session alive' by going to different pages all the time. even though every 10 minutes i check for messages with a PHP script (one of many) it doesn't see it as activity and as such the session expires. Any suggestions on how i can keep renewing the session every x minutes, or every time a script is executed? Or whether or not i can check if a session has expired and have access to what WAS in the session and reset it again? A friend of mine said something about using time() and the Epoch, which i know about but i dont quite see how it's going to help. It can tell me if a session is about to expire, but then what, how do i 'restart' it while keeping all the values? Any help would be handy. :) Quote Link to comment https://forums.phpfreaks.com/topic/150842-renewing-a-session/ Share on other sites More sharing options...
redarrow Posted March 24, 2009 Share Posted March 24, 2009 can we see some php code related to your set session's, sounds like it not written properly. Quote Link to comment https://forums.phpfreaks.com/topic/150842-renewing-a-session/#findComment-792401 Share on other sites More sharing options...
theinfamousmielie Posted March 24, 2009 Author Share Posted March 24, 2009 Hi there, thanks for the response I think you may have misunderstood me, the sessions are being set just fine, and they last, just as expected (i set it to 3600 seconds ... 1 hour) but i want to know if i can keep resetting it every time a script is accessed, thus granting a further 3600 seconds of 'idle time'. At the moment, i start off with session_set_cookie_params(3600); session_start(); and any scripts that launch 'applications' via AJAX just use session_start(); which mostly seems to get ignored. But have no fear, i've decided that for the sake of my sanity and the stupidity of users, i'm going to have infinite sessions. I must just make sure that they cannot be hijacked. Quote Link to comment https://forums.phpfreaks.com/topic/150842-renewing-a-session/#findComment-792406 Share on other sites More sharing options...
PFMaBiSmAd Posted March 24, 2009 Share Posted March 24, 2009 session_set_cookie_params(3600) only sets the cookie lifetime. That is how long the cookie will be retained when the browser is closed. This has nothing to do with someone having requested a page from your site that started a session and they still have their browser open. What is the URL of your main page and the URL that ajax requests. xxxxx out any sensitive information, like the domain name, but don't change any of the hostname/path parts. Quote Link to comment https://forums.phpfreaks.com/topic/150842-renewing-a-session/#findComment-792580 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.