gerkintrigg Posted March 10, 2007 Share Posted March 10, 2007 Hi all. I'm writing a cookie with the following code: setcookie("mem", "yes", time()+7200,"/shop/","allpet.co.uk"); And I'm reading it from another page with: $ul_mem = $HTTP_COOKIE_VARS["mem"]; but the second page does not recognise it. Is there soemthing I'm doing wrong? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/42105-solved-cookies-being-read/ Share on other sites More sharing options...
wildteen88 Posted March 10, 2007 Share Posted March 10, 2007 HTTP_COOKIE_VARS is depreciated. Use $_COOKIE instead. This go for all the other HTTP_*_VARS variables. Example: $HTTP_POST_VARS should be $_POST $HTTP_GET_VARS should be $_GET ALso note that you cannot use and set cookies that where set on the same page. You will have to refresh the page in order for the cookie that you just set to come available. However if you are setting and using cookies on seperate pages then you dont need to refresh. Quote Link to comment https://forums.phpfreaks.com/topic/42105-solved-cookies-being-read/#findComment-204225 Share on other sites More sharing options...
gerkintrigg Posted March 10, 2007 Author Share Posted March 10, 2007 thanks, but it's not made any difference Quote Link to comment https://forums.phpfreaks.com/topic/42105-solved-cookies-being-read/#findComment-204238 Share on other sites More sharing options...
per1os Posted March 10, 2007 Share Posted March 10, 2007 try this setcookie("mem", "yes", time()+7200,"/shop","/"); OR setcookie("mem", "yes", time()+7200,"/shop","allpet.co.uk"); If that does not work, read up on cookies here: http://us3.php.net/manual/en/function.setcookie.php It explains about the domains and paths etc. If this is running on Localhost, you need to set the domain part to false, remember that. --FrosT Quote Link to comment https://forums.phpfreaks.com/topic/42105-solved-cookies-being-read/#findComment-204241 Share on other sites More sharing options...
gerkintrigg Posted March 11, 2007 Author Share Posted March 11, 2007 Sorry I was being dumb... I forgot the underscore when I called the $_COOKIE variable... I just did $COOKIE which did very little. Sorry to bother you and thanks for all your help. Quote Link to comment https://forums.phpfreaks.com/topic/42105-solved-cookies-being-read/#findComment-204901 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.