Page 1 of 1

Cookies

PostPosted: 13. January 2008 17:29
by mightymouse3062
I am having a problem setting cookies. Here is the code that I use:

$cookie_site_name = "";
$cookie_site_name_path = "";
setcookie("logged_in", 1, time()+604800, "$cookie_site_name_path", "$cookie_site_name");
setcookie("username", $login_username, time()+604800, "$cookie_site_name_path", "$cookie_site_name");

for the $cookie_site_name I have tried leaving it blank, deleting it, using localhost, 127.0.0.1, 192.168.1.3 (my computers ip address).
for the $cookie_site_name_path I have tried leaving it blank, deleting it, and using /, /system, /system/, system/. (system is the folder that I have the site in).

What I will be doing is using it for a administration system for a tournament and I am going to be creating an network so the system can be accessed from multiple computers. The only way I have been able to do this so far is by using the computers IP address. The problem I am having is it will not set any cookies.


Does anyone have an idea on why it is doing this or a way to fix it?

Thanks,
Mightymouse3062

PostPosted: 13. January 2008 17:37
by Scory
How do you check the cookies? Code example?

Greets
Scory

PostPosted: 13. January 2008 17:39
by mightymouse3062
if(isset($_COOKIE['logged_in']) == 1){
$logged_in = 1;
$logged_in_userid = $_COOKIE['username'];
}

PostPosted: 13. January 2008 20:55
by Scory
Maybe it's a problem of InternetExplorer (or other browser), are you sure that cookies are allowed for the specified domains?

PostPosted: 14. January 2008 00:21
by mightymouse3062
It is something within XAMPP because this code works perfectly fine when it was on my web server (webhostingbuzz shared1 server). I use Firefox and I have tried IE and they both have the same problem that it wont work.

PostPosted: 14. January 2008 17:25
by Scory
You should enable full error logging and see, if an error message occurs.

But there is no server specific reason for cookies not working - I never heard about any problems, as the server does not store cookies nor retrieve them. They are part of the HTTP Headers.

PostPosted: 14. January 2008 18:26
by RandomZero
I know nothing about this, but I thought I'd offer up some advice anyway.

Try using the web address maybe?

PostPosted: 14. January 2008 19:09
by mightymouse3062
I dont know what I did to fix it, but it works now. I set $cookie_site_name_path = "/"
$cookie_site_name = "127.0.0.1"

I tried it before and it didnt work and now it does...

Thanks for your help,
Mightymouse3062