Page 1 of 1
Cookies not being set...Why?
Posted: Sat May 20, 2006 9:02 pm
by arctictiger
Hi,
I'm fairly new to php so please be patient with me if this is a stupid ass question.
I'm trying to get my site to set a cookie using this code:
Code: Select all
<?php
setcookie("uname", $name, time()+36000);
?>
<html>
<body>
<p>
A cookie was set on this page! The cookie will be active when
the client has sent the cookie back to the server.
</p>
</body>
</html>
All well and good as this is a tutorial from w3schools.com however this code has worked once, but then I tried to impliment it into my site and it no longer works, so I went back to try and use just that code again and now it doesn't work at all. No cookie is being set with that code and I was wondering if anyone know what the problem might be.
Cheers
Posted: Sat May 20, 2006 10:05 pm
by RobertGonzalez
1. Is your browser set to accept cookies?
2. Have you cleared your browsers cache?
3. How are you testing for the set cookie?
Re: Cookies not being set...Why?
Posted: Sun May 21, 2006 3:03 am
by arctictiger
1. Yeah
2. Yeah
3. Running the script from my site then checking in my cookies folder on my machine.
All other sites leave cookies on my machine but that script wont work for some reason.

Posted: Sun May 21, 2006 4:18 am
by someberry
How are you testing to see if the variable is set? It should be:
If that doesn't work, try clearing the cookie doing something like:
Code: Select all
setcookie("uname", $name, time()-1000);
And then trying again. Remember that you cannot use the cookie on the same page at the time you created it.
Posted: Sun May 21, 2006 5:37 pm
by arctictiger
Nope, this has no affect at all.
I'm sorry to bother you with this, must be something happening with my server.

Posted: Sun May 21, 2006 6:00 pm
by arctictiger
Ok I'm a comlete and utter n00b.
Somehow firefox had blocked my site. I feel like such a tit.
Plentiful amounts of flamming will be appreciated.
Sorry to waste your time
Posted: Sun May 21, 2006 6:44 pm
by Chris Corbyn
Sometime's the must irritating problems have to simplest solutions

Glad you got it sorted

Posted: Sun May 21, 2006 7:23 pm
by RobertGonzalez
arctictiger wrote:
Ok I'm a comlete and utter n00b.
Somehow firefox had blocked my site. I feel like such a tit.
Plentiful amounts of flamming will be appreciated.
Sorry to waste your time
It has happened to all of us at some point. Glad to see you figured it out.