View Full Version : Cookie error strikes again!
beetle
08-13-2002, 02:42 PM
Howcome the line below will add a cookie to my WinXP/IE6 machine, but not to my Win2K Adv Srvr/IE5 machine?setcookie("sess_key",$this->key,time()+3600);Yes, I've already made sure that cookies are enabled. :D
mordred
08-13-2002, 06:54 PM
I remember vaguely that IE5 is picky with cookies that have not all options specified. Does it work when you try to set each parameter with at least a default value?
Also, there might be more on this in the user notes.
beetle
08-13-2002, 07:40 PM
I have changed up the code so that ALL values are present, still a problem. Grrrr.
http://www.microsoft.com/products/shared/images/bnrie.gif http://www.simonsgroup.com/siteimages/s/bigun2.gif
Socraties
08-13-2002, 07:42 PM
I myself have had a lot of issues with cookies and have found some interesting things about them on microsoft's site. I had a good post with the info on WA's site. Here is a sure fire way that I have found to set a cookie no matter the browser or OS.
<?
ob_start(); //stops sending to browser to set cookie.
setcookie("session",$Session_ID,time()+3600);
ob_end_flush();/ starts sending to browser after cookie is set.
?>
beetle
08-13-2002, 08:15 PM
Oh ya...I've read about that too but it got stashed away in the dusty recesses of my mind's attic. thanks....However, it still isn't working. I made a testing page that is just this<?php
if (isset($_GET['check'])) {
ob_start();
foreach($_COOKIE as $val)
echo($val."<br>");
setcookie("sess_key","Yummy cookie",time()-3600,"","www.lanwizards.com",0);
ob_end_flush();
}
else {
ob_start();
setcookie("sess_key","Yummy cookie",time()+3600,"","www.lanwizards.com",0);
ob_end_flush();
}
?>
<input type="button" value="Check Cookie" onClick="window.location.href='<?=$PHP_SELF?>?check=1'"> And it's STILL not writing a cookie. I've concluded that either it's just IE5, or that machine in specific that sux. Here's think link to my tester page (the source above)
www.lanwizards.com/test2.php
If it works ok for you in IE5, let me know.
mordred
08-13-2002, 09:26 PM
"Yummy cookie" for me with IE5.5 on Win2k. Though the page itself was loading painfully slow.
pager
08-14-2002, 03:14 AM
I've got cookie proc issues at the moment, and I was thinking the same thing.... that maybe I haven't spec'd all the required vals etc.. but I checked your link and I got yummy too.
Socraties
08-14-2002, 06:40 PM
I am gonna have to say it is that machine. I got the cookie using IE5 as well. I would try re-loadinig IE5.
beetle
08-30-2002, 05:04 PM
Hey all
A while ago I posted (http://www.codingforums.com/showthread.php?s=&threadid=3939) about a cookie problem I was having. For a while I though it was just the one machine (Win 2000 Adv Server, IE5) But now it has happened in other places. I've setup a simple demo page that uses the exact method to store cookies that my sight does, but for some reason certain machines aren't storing it.
Here's the page (http://www.lanwizards.com/test2.php)
And here's the source for that page<?php
if (isset($_GET['check'])) {
ob_start();
foreach($_COOKIE as $key => $val)
echo($key." = ".$val."<br>");
setcookie("test_cookie","Yummy cookie",time()-3600,"","www.lanwizards.com",0);
ob_end_flush();
}
else {
ob_start();
setcookie("test_cookie","Yummy cookie",time()+3600,"","www.lanwizards.com",0);
ob_end_flush();
}
?>
<input type="button" value="Check Cookie" onClick="window.location.href='<?=$PHP_SELF?>?check=1'">
Help!
boxer_1
08-30-2002, 05:27 PM
I've merged your most current thread with the previous one as the question is essentially in regard to nearly the same issue with the exception of a few new twists. It should help others to follow along with the discussion and defragment the 2 threads ;). Good luck ;).
For what it's worth, I halso had endless problems in trying to create COOKIES on the client machines.
The solution for me was a simple one.
have a look in your php.ini
output_buffering = on
The rules are that header information must be sent through to the browser before any output is sent. Otherwise it will be ignored. The PHP designers saw this as a problem, because the code allows you to create, write to and kill cookies in a programmatically logical way, but if that darn thing goes through with the ouput...it's too late... Hence the birth off output buffering. If set to on the page is written to a buffer before it is sent. In buffering the output, the file is ordered and headers and content etc. gets grouped together.
And siedaar...the cookie goes through before output is sent.
:)
Hope it helps:D
beetle
09-05-2002, 07:20 PM
Well, it did, sort of.
When I ran my testing page again, I now get a new value
cookies = true
but it doesn't store/retrieve the cookie I'm trying to set, which should ouput
test_cookie = Yummy cookie
Do I need different ob functions?
In setting output_buffering = on in php.ini all pages are buffered by default.
This means the use of ob_start() and ob_end_flush() becomes redundant, because all script are buffered and sorted before post.
beetle
09-06-2002, 05:00 PM
I see. Still not working though
:mad: http://www.sitepointforums.com/images/smilies/splat.gif http://www.sitepointforums.com/images/smilies/kaioken.gif http://www.sitepointforums.com/images/smilies/brickwall.gif http://www.sitepointforums.com/images/smilies/crash.gif
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.