Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/42105-solved-cookies-being-read/
Share on other sites

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.

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.