RE: [PHP-WIN] RE: problem with cookies
| From: | Thomas Kryger | Date: | Thu, 19 Oct 2000 13:58:37 +0000 |
| Subject: | RE: [PHP-WIN] RE: problem with cookies | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-3380@lists.php.net to get a copy of this message | ||
Hi
I had problems with cookies when running PHP4.0.x as a ISAPI under IIS5.
Doing it the CGI-way worked.
Thomas D. Kryger
FICS Danmark
-----Original Message-----
From: afan [mailto:afan@sprout.net]
Sent: Thursday, October 19, 2000 2:17 AM
To: php-windows@lists.php.net
Subject: [PHP-WIN] RE: problem with cookies
Same problem!
It shows me allways that "I've seen this site 1 time".
If I take out part "time()+10" it works perfect.
What to try now?
Afan
---------------------------
afan wrote:
I'm trying set cookie. I use small script I found in book "Professional
PHP programming" writen by Jesus, Harishm, Sascha, Chris and Deepak. This is
a script: <?php$count++;setcookie("count", $count);?>You have seen this site
$count times! and script works fine. Everytime I refresh page I get next
number (1, 2, 3, 4...) But, when I try to put expiration it doesn't work
anymore - I get alway number 1: <?php$count++;setcookie("count", $count,
time() + 10);// I put 10 sec only - easy to see when cookie expires.?>You
have seen this site $count times! What I'm doing wrong?
Well, not to say you're doing anything wrong... BUT here's a script that
works (a slight restructuring around HTML, and adding an <? echo... ?>
statement around the $count variable in the page display... try this and see
if it works for you... Also, make sure you actually wait the full 10 seconds
before reloading to check if the expiration is working.
**** My Cookie Test ****
<?php
$count++;
setcookie("count", $count, time() + 10);
?>
<html>
<head>
<title>Cookie Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF">
<p><b>Cookie Test</b></p>
<p>You have seen this site <? echo $count; ?> times!</p>
<p><? echo time(); ?></p>
<p>What is the result???</p>
</body>
</html>
**** End of Cookie Test ****
Andy Hoffman
Web Developer
Bristol-Myers Squibb
email: andy.hoffman@bms.com