Languages :: PHP :: relationship between $_COOKIE and $_SESSION ?? |
|||
| By: Bernard |
Date: 31/12/2004 09:15:58 |
Points: 40 | Status: Answered Quality : Excellent |
|
Hi, I need to destroy one variable in $_COOKIE (from a javascript appl.) and, because i don't use other $_COOKIE variables, I tried to do a brutal "unset($_COOKIE)" however, when doing this before the 'session_start()' at the beginning of my script, the session is no more reachable (login lost, other session variable lost) what the hell is the relation between Cookie and session in PHP ??? |
|||
| By: VGR | Date: 31/12/2004 09:21:36 | Type : Answer |
|
| The session ID is stored in a cookie on the users machine! By unsetting the cookie, you are destroying the reference to the session and so no session ID is given and the session is all lost. and the server has also (usually) a "server cookie" on its own, containing all your session variables's values... and named after the sessionID :D instead of unsetting all cookies, just delete the particular cookie you need. I don't think unset($_COOKIE) will actually destroy any cookies on the browser, it will just make them unreadable for the current PHP script. This is probably why session_start() isn't working. To delete a cookie from the browser, you need to use setcookie() and pass an expiration time in the past, with an empty string as the value. setcookie('deleteme', '', time() - 3600); |
|||
| By: Bernard | Date: 10/01/2005 09:25:20 | Type : Comment |
|
| parfait, très clair, merci | |||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








