Deleting PHPSESSID

0

I'm making a cart with $_SESSION and when the purchase is finished, I should clean or delete the PHPSESSID (which is auto-created). But I'm not able to delete or update. I've tried with unset() and session_destroy() and even trying to delete as cookie , but I'm not getting anything.

    
asked by anonymous 22.01.2018 / 07:10

2 answers

1

The session_destroy function will not delete the PHPSESSID , it will just remove the entire contents of the $_SESSION variable. This function does not remove the session cookie.

  

Just remembering that session_destroy does not remove data from $_SESSION at the time it was executed, but rather at the next request.

If you want to clear all data from the $_SESSION variable, just use session_reset . This function will erase all data from the above variable at the time it is run.

Particularly I see no reason to delete the value of PHPSESSID since you can use the functions above or even unset .

But if you really want to remove this cookie, just use the setcookie a>.

setcookie(session_name(), null, 0);
    
22.01.2018 / 11:38
2

Have you tried this:
Do ( link ), "Note: It is not necessary to call session_destroy () in a custom code. Instead of destroying session data, clear the $ _SESSION array."

    
22.01.2018 / 11:25