Keeping time of PHPSESSID

setcookie('myCookie', 'my_cookie_value', time()+5, '/', ' .my.domain');

With the code above “myCookie” wil be removed after 5 seconds.

session_set_cookie_params(0, '/', ' .'.my.domain.'');

With the code above “PHPSESSID” will be created.

I like to remove the cookie “PHPSESSID” after 5 seconds like “myCookie”.

The following is one of my trials for it, but it seems not to work as I expected.

session_set_cookie_params(time()+5, '/', ' .'.my.domain.'');

How can I remove the cookie “PHPSESSID” after 5 seconds?

From what I can gather, while you have a session open this is how PHP identifies it. So I draw from that, if you remove that cookie, your session information will also be lost.

1 Like

You don’t. As mentioned in your other post, if you want to kill the session cookie, you have to destroy the session!

1 Like

PHPSESSID is basically the session cookie. That cookie remembers everything you’ve used from the super global $_SESSION. Stuff in $_SESSION will never be displayed, but to keep those values in place, PHPSESSID is needed. If you delete or “kill” this session if you will, everything that is within that session for the current user is automatically removed or changed. The next time the user views the same page, they will get a new session and their information will not be in the new session.

I don’t understand your intentions of “killing” the session, but as @Gandalf has mentioned above and in your other thread, to properly “kill” or destroy a session, you have to call the function session_destroy.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.