This is a discussion on setcookie() won't set the cookie within the PHP General forums, part of the PHP Programming Forums category; Hi all! This is really driving me crazy but i cannot figure out why a simple php script won't ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi all!
This is really driving me crazy but i cannot figure out why a simple php script won't set a cookie on my machine, but works just fine on my girlfriends machine. The first script setcookie.php is: <? $value = 'test'; setcookie ("testCookie", $value, time()+3600); header("Location: showcookie.php"); ?> and the other script getcookie.php is: <? if (isset($_COOKIE['testCookie'])) {print $_COOKIE['testCookie'];} else {print "cookie 'testCookie' is not set";} ?> it just always gives me a "cookie 'testCookie' is not set" all the time. My privacy setting in IE6 is set to the lowest "Accept All Cookies" and i had no luck in Netscape or Opera either. I'm running Windows XP, Apache 2, PHP 4.3.2 and my girlfriend's machine runs the same, I even replaced my php.ini with hers, but it still won't help. I tried to use header("Set-cookie:testCookie=$value") instead of setcookie() or $HTTP_COOKIE_VARS instead of $_COOKIE, but still no luck. I finally reinstalled PHP and Apache, but still cannot make it work. I just ran out of ideas what else I can do to make it work on my machine. Anyone got a clue on this? Thank you. |
|
|||
|
I figured out what was the problem.
It was my ZoneAlarm Pro 3.7.159. Even though its privacy setting 'Cookie control' was set to off, I moved the slider up and down just to make sure it was off and also reset the ad blocking setting from medium to Off and bingo! my cookie setting script was working. So stupid. I went through so much trouble to realise it was ZoneAlarm's bug. I better get an update. |