-1

I have seen many topics where people tried to keep a Php session for a year but in some cases when they close the browser the session times out on mobile or on desktop. Here is how to keep your session active with Php both on mobile or desktop version even when the user closes the Browser.

John Max
  • 432
  • 8
  • 23
  • Not my downvote on anything in here, but this was already asked and quite a few times John. I took that duplicate from someone else posting it in comments, just so you know. – Funk Forty Niner Feb 01 '17 at 16:39

1 Answers1

-1

All you have to do is to keep this code at the top of your page everytime you want to do a session_start(), instead input this code

$expire = 365*24*3600; // We choose a one year duration

ini_set('session.gc_maxlifetime', $expire);

session_start(); //We start the session 

setcookie(session_name(),session_id(),time()+$expire); 
//Set a session cookies to the one year duration

Hope this helps someone out there

John Max
  • 432
  • 8
  • 23