Gafaddict Posted June 4, 2011 Share Posted June 4, 2011 I am using the Tool Man script, a script that allows one to "drag and drop" the position of a list of elements. It uses cookies to pass the information from one page to the next. When I try to use PHP to clear the value of this cookie, it doesn't work. I have a suspicion that this has something to do with the fact that the cookie was set in JavaScript, because if I try to clear a cookie which I set in PHP, it clears easily. The code I am using to clear is: setcookie("list_boxes", "", time() - 3600); The script that Tool Man uses to set cookies can be found at: http://tool-man.org/source/org/tool-man/cookies.js Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/238375-setting-cookies-in-javascript-then-clearing-them-in-php/ Share on other sites More sharing options...
DaiLaughing Posted June 4, 2011 Share Posted June 4, 2011 There should be no difference in a cookie just because of where it came from. Have you looked at the actual cookie contents at each stage inside your browser? Another thought is whether the JavaScript is recreating the cookie based on the presence of other cookies or another factor. Quote Link to comment https://forums.phpfreaks.com/topic/238375-setting-cookies-in-javascript-then-clearing-them-in-php/#findComment-1225073 Share on other sites More sharing options...
PFMaBiSmAd Posted June 4, 2011 Share Posted June 4, 2011 You must use the same parameters that were used when the cookie was created. When the parameters don't match, you are trying to clear a different cookie that probably doesn't exist. The set function is setting the path to /. In order to match that cookie, you need to set the 4th parameter in the setcookie() function call to '/' Quote Link to comment https://forums.phpfreaks.com/topic/238375-setting-cookies-in-javascript-then-clearing-them-in-php/#findComment-1225074 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.