Page 1 of 1

Session Cookie Problems

PostPosted: 06. November 2007 08:20
by kthxbai2u
I'm not sure if this is a problem with the way my server is configured... or if it is a problem with my programming code. Basically, I set a cookie using

Code: Select all
setcookie("name","test", (time() + (60*2)), "/", ".codinggroundz.com", 0);


Now, that part works fine, because I can see the cookie with firefox. I can see its unencrypted contents.

But... When I try to

Code: Select all
echo "Welcome back, ".$_COOKIES["name"];


it returns nothing O_o I think it may have something to do with the url not matching the server name... so it wont allow to retrieve that cookie. but i checked that. looks normal to me. iono :shock:

[edit] my entire project has come to a grinding halt because of this,.. Someone please help me! :([/edit]

nevermind.... >.<

PostPosted: 06. November 2007 11:59
by kthxbai2u
I kept reading, and sorting through all the garbage google spat at me, and everyone else had a different way of doing things, and sucked at explaining it... Most of the code examples had errors... I found that I was just setting the subdomain wrong when i set the cookie... thx :)

changed:
Code: Select all
setcookie("name","test", (time() + (60*2)), "DevCopy/", ".codinggroundz.com", 0);


To:
Code: Select all
setcookie("name","test", (time() + (60*2)), "/DevCopy", ".codinggroundz.com", 0);



And then finally to:
Code: Select all
setcookie("name","test", (time() + (60*2)), "/DevCopy/", ".codinggroundz.com", 0);