Page 1 of 1

cookie problems

PostPosted: 14. October 2006 17:53
by lumpylemon
no matter what i try, i just can't seem to get cookies to work in xampp!

my code works fine on my 'real' server, but not on my machine here at home when running xampp.

does anyone know how i get the following line to work in xampp?:

Code: Select all
setcookie("style", $theStyle, time()+36000, "/", "localhost");


should i be changing either '/' or 'localhost' to something else?

also, it seems that $HTTP_REFERER is not being sent, so my php cookie script cannot redirect the user automatically back to the referring page using this line:

Code: Select all
header("Location: $HTTP_REFERER");


any suggestions most welcome before i tear all my hair out!

cheers
simon

PostPosted: 14. October 2006 19:11
by Wiedmann
Code: Select all
setcookie("style", $theStyle, time()+36000, "/", "localhost");

Don't use the path and domain parameter for localhost cookies.

also, it seems that $HTTP_REFERER is not being sent

a) I don't know if your browser send a referer after a link.
b) the variable "$HTTP_REFERER" exists? You have assigned a value to this variable?

If you want use the value of the referer for the redirect, you must use "$_SERVER['HTTP_REFERER']" in the function header(). (and don't forgett, not all browsers send a referer)

PostPosted: 30. October 2006 18:27
by Bantamanick
I can't get cookies to work either and that's without using path and domain parameter.

Code: Select all
setcookie ("sessionid", md5 (uniqid (rand())), time()+7200);


I suspest you're in the same boat as me, a configuration problem.

Nick

PostPosted: 01. November 2006 21:40
by rob2006
I have found a solution:

use http://127.0.0.1 instead of just http://localhost

from what i have found its todo with how cookies need a something.something domain name, but Im open to better (more correct?) reasons.

Whether you can configure php or apache to allow both I dont know, any offers?