bob_the _builder Posted September 16, 2012 Share Posted September 16, 2012 Hey, I have set $_SESSION['cart'] Array ( [sDBVVHR] => 1 [bMNHYR] => 1 ) those are in the cart array.. When I send the variable "BMNHYR" across the url.. and try to unset the matching session variable, I cant seem to get it to work.. How should it be formated? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/268419-cant-seem-to-unlink-a-session-variable/ Share on other sites More sharing options...
requinix Posted September 16, 2012 Share Posted September 16, 2012 What's your code? Quote Link to comment https://forums.phpfreaks.com/topic/268419-cant-seem-to-unlink-a-session-variable/#findComment-1378272 Share on other sites More sharing options...
bob_the _builder Posted September 16, 2012 Author Share Posted September 16, 2012 I thought something like $code = $_GET['code']; unset ($_SESSION['cart']['$code']); Quote Link to comment https://forums.phpfreaks.com/topic/268419-cant-seem-to-unlink-a-session-variable/#findComment-1378278 Share on other sites More sharing options...
Adam Posted September 16, 2012 Share Posted September 16, 2012 Variables within single quotes are not parsed, so you're literally trying to delete '$code'. You could use double quotes (which are parsed), but there's no reason to wrap just a variable in quotes anyway. Drop the quotes.. Quote Link to comment https://forums.phpfreaks.com/topic/268419-cant-seem-to-unlink-a-session-variable/#findComment-1378279 Share on other sites More sharing options...
bob_the _builder Posted September 16, 2012 Author Share Posted September 16, 2012 Sorry that was while playing with variations to make it work.. originally there were no quotes and still didnt work.. Is it to do with the number in the session variable [bMNHYR] => 1? Quote Link to comment https://forums.phpfreaks.com/topic/268419-cant-seem-to-unlink-a-session-variable/#findComment-1378292 Share on other sites More sharing options...
Christian F. Posted September 16, 2012 Share Posted September 16, 2012 First step is to finding out exactly what the variables contain, and verify that it is what you assume/expect it to be. Second step is to actually post all relevant information, if you want help, so that people don't have to waste time pulling your teeth to get the information they need. You should have been here long enough to know this by know, to be honest... Quote Link to comment https://forums.phpfreaks.com/topic/268419-cant-seem-to-unlink-a-session-variable/#findComment-1378302 Share on other sites More sharing options...
bob_the _builder Posted September 16, 2012 Author Share Posted September 16, 2012 Thanks for the wise words ChristianF.. The page was being called via a jquery function into a div.. I forgot to put session_start(); at the top of the page Sorry team, thanks for the help Quote Link to comment https://forums.phpfreaks.com/topic/268419-cant-seem-to-unlink-a-session-variable/#findComment-1378314 Share on other sites More sharing options...
Christian F. Posted September 16, 2012 Share Posted September 16, 2012 You're welcome, glad we could help. Also, thanks for letting us know what was wrong and how you fixed it. Quote Link to comment https://forums.phpfreaks.com/topic/268419-cant-seem-to-unlink-a-session-variable/#findComment-1378323 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.