cookie problems

Problems with the Windows version of XAMPP, questions, comments, and anything related.

cookie problems

Postby lumpylemon » 14. October 2006 17:53

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
lumpylemon
 
Posts: 2
Joined: 24. May 2005 15:55

Postby Wiedmann » 14. October 2006 19:11

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)
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Postby Bantamanick » 30. October 2006 18:27

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
Bantamanick
 
Posts: 4
Joined: 10. October 2006 10:15

Postby rob2006 » 01. November 2006 21:40

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?
rob2006
 
Posts: 3
Joined: 30. October 2006 09:01


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 132 guests