...

View Full Version : Cookie doesn't store in IE



Crazydog
07-27-2007, 07:10 PM
This cookie:


setcookie("login", 1, time() + 7200, '/');


Doesn't work when it is called in IE using this:



$cookie = $_COOKIE['login'];

why doesn't it work?

whizard
07-27-2007, 07:11 PM
Are you implyingthat it DOES work in other browsers, eg FF, Opera, or are you saying the only browser you tested it in is IE?

We're gonna need more info to work on this one.

Dan

Crazydog
07-27-2007, 07:12 PM
yea, it does work in FF..
doesn't work in IE or opera or safari

Also, I'm testing this over a LAN, so the URL is http://10.1.1.12 if that makes a difference...

whizard
07-27-2007, 07:14 PM
Check your IE cookie settings?

Dan

Crazydog
07-27-2007, 07:17 PM
I set all my IE settings down to the lowest....
I tested it in opera and safari, doesn't work in those either

_Aerospace_Eng_
07-27-2007, 07:18 PM
Hmm I wouldn't create a login cookie as cookies can be made on the fly by the user with the right software. A session would be better as its stored on the server.

whizard
07-27-2007, 07:21 PM
maybe try setting the domain to localhost?

(http://us2.php.net/manual/en/function.setcookie.php)

...or would that not work on a LAN? I don't know actually.

HTH
Dan

rafiki
07-27-2007, 07:27 PM
use sessions, so much easier and more convenient.

whizard
07-27-2007, 07:30 PM
@rafiki

True, but if he wants his site to 'remember' visitors, he needs to use cookies, right?

Dan

_Aerospace_Eng_
07-27-2007, 07:32 PM
@rafiki

True, but if he wants his site to 'remember' visitors, he needs to use cookies, right?

Dan
No sessions will work just as well as they will store whatever value you want them to.

Crazydog
07-27-2007, 07:35 PM
the problem was it being a LAN address.


when I put it on a webserver with a domain, it worked fine in the other browsers

whizard
07-27-2007, 07:36 PM
@crazy
Glad it works

@Aero
Aren't sessions ended when the browser is closed?

Dan

_Aerospace_Eng_
07-27-2007, 07:39 PM
@crazy
Glad it works

@Aero
Aren't sessions ended when the browser is closed?

Dan

Nope. The server takes care of when the session ends. Usually its about 45 minutes but on one server I have this set to 7 days so it never ends until the user logs out from the site.

whizard
07-27-2007, 07:41 PM
oh cool. Thanks for the info!

Dan

_Aerospace_Eng_
07-27-2007, 07:43 PM
Take that back. The default is 1440 seconds so that divided by 60 will get you the number of minutes the session lasts but you can use ini_set or htaccess to set the session max lifetime. This is what I use in an .htaccess file

php_value session.save_path /usr/home/username/sessions
php_value session.gc_maxlifetime 2419200
php_value session.cookie_lifetime 604800
If you server allows the changing of php values using htaccess then this should work.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum