PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
arctictiger
Forum Newbie
Posts: 4 Joined: Mon Oct 24, 2005 5:47 pm
Post
by arctictiger » Sat May 20, 2006 9:02 pm
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
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Sat May 20, 2006 10:05 pm
1. Is your browser set to accept cookies?
2. Have you cleared your browsers cache?
3. How are you testing for the set cookie?
arctictiger
Forum Newbie
Posts: 4 Joined: Mon Oct 24, 2005 5:47 pm
Post
by arctictiger » Sun May 21, 2006 3:03 am
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.
someberry
Forum Contributor
Posts: 172 Joined: Mon Apr 11, 2005 5:16 am
Post
by someberry » Sun May 21, 2006 4:18 am
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.
arctictiger
Forum Newbie
Posts: 4 Joined: Mon Oct 24, 2005 5:47 pm
Post
by arctictiger » Sun May 21, 2006 5:37 pm
Nope, this has no affect at all.
I'm sorry to bother you with this, must be something happening with my server.
arctictiger
Forum Newbie
Posts: 4 Joined: Mon Oct 24, 2005 5:47 pm
Post
by arctictiger » Sun May 21, 2006 6:00 pm
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
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Sun May 21, 2006 6:44 pm
Sometime's the must irritating problems have to simplest solutions
Glad you got it sorted
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Sun May 21, 2006 7:23 pm
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.