Question

As first, I know a lot questions are like mine, but I really don't know what I'm doing wrong...

As you might've guessed, I've a PHP script involving sessions. Everything works like a charm, except setting the lifetime of my session.

I want to keep the session active for two weeks, but instead my (Chrome) browser says it's set to xpire after the browsing session (and it does). My PHP script:

session_name('DSWLogin');
// Naming the session

session_set_cookie_params(2*7*24*60*60);
// Making the cookie live for 2 weeks

session_start();
// Starting the session

It really doesn't work.

Thanks in advance,

Isaiah

Was it helpful?

Solution

Rewrite your code as

session_start();
setcookie(session_name('DSWLogin'),session_id(),time()+2*7*24*60*60);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top