Jump to content

Session refreshing


astralaaron

Recommended Posts

When my site sits open for a bit the logged in sessions for a user will expire and functions start failing until they re-log in.I have 2 questions. First if the page was reloaded and session_start() is called again, are all session variables refreshed? And second, if my site doesn't completely reload and instead uses AJAX calls that loads different parts of the program into one main view; will all of the sessions refresh still if the session_start() is called on the page that AJAX requested?

Link to comment
Share on other sites

Well, session_start() starts session or continue already started. I like to useif (session_id() == '') { session_start(); }to avoid getting error "headers already sent". So maybe it may help you to not start it again.

Link to comment
Share on other sites

If you're using an ajax application, set up an ajax request on a timeout interval to run every 10 or 15 minutes and have it send a request to a page that will use session_start. That will keep your session alive for as long as they are on the page, as long as those requests keep firing.

Link to comment
Share on other sites

If you're using an ajax application, set up an ajax request on a timeout interval to run every 10 or 15 minutes and have it send a request to a page that will use session_start. That will keep your session alive for as long as they are on the page, as long as those requests keep firing.
thanks, that's what I needed to hear. I had an interval that would log you out if you didnt click keep me logged in when it popped up but nothing was refreshing the session.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...