Michael
Michael

Reputation: 53

PHP custom session mechanism - and cookie expire problem

I'm using session_set_save_handler() to keep my session in Redis, and everything works perfectly, except one thing. after hours and hours of pulling my hair I thought I should just ask someone. so, on the server side, I set the session life for X minutes. on each page refresh, the session life is set to X minutes, but on the browser the cookie expires after exactly 30 minutes after the first page load. how can I force the cookie life to be extended on each page refresh like on the server side. any thoughts?

Upvotes: 4

Views: 589

Answers (1)

netcoder
netcoder

Reputation: 67685

Try something like:

session_start();
setcookie(session_name(), session_id(), strtotime('NOW+30MINUTES'));

Upvotes: 1

Related Questions