Cookies not setting

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

Post Reply
robjime
Forum Commoner
Posts: 46
Joined: Sat Apr 03, 2004 12:26 pm
Location: the RO

Cookies not setting

Post by robjime »

<?php
$value = 'something from somewhere';

setcookie("TestCookie", $value);
?>
even when I just used the code from php.net my cookies won't set, any ideas
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

bool setcookie ( string name [, string value [, int expire [, string path [, string domain [, int secure]]]]])

If you don't give it the expire option then the cookie expires at the end of the session (when the browser closes), sure you're not getting this behaviour?
robjime
Forum Commoner
Posts: 46
Joined: Sat Apr 03, 2004 12:26 pm
Location: the RO

Post by robjime »

nope that didn't work either, even when i left the window open it still didn't go?

http://robjime.vzz.net/cookie.php
User avatar
launchcode
Forum Contributor
Posts: 401
Joined: Tue May 11, 2004 7:32 pm
Location: UK
Contact:

Post by launchcode »

Didn't go where? What code are you using to check the cookie exists?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

you may want to try the following

Code: Select all

setcookie("TestCookie",$value,0,'/');
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

The link above sets a cookie ok for me *shrug*
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

hehe. i think that u can try best what Feyd posted up there.. especially the '/' in the fourth place
Post Reply