suzuking
suzuking

Reputation: 23

PHP setcookie doesn't work on IE8

the following code doesn't work on IE8. i tried print_r ($_COOKIE) but it returned array(); please help me.

  1 <?php
  2 $currentTime = time();
  3 
  4 $cookieName   = "go.hyde";
  5 $cookiePath   = "/";
  6 $cookieDomain = $_SERVER['SERVER_NAME'];
  7 $cookieValue  = strval($currentTime);       // value is issue time (Unix Time)
  8 $cookieExpire = strval($currentTime + 600); // expire is 10 minutes after issuing cookie
  9 
 10 setcookie($cookieName,
 11     $cookieValue,
 12     $cookieExpire,
 13     $cookiePath,
 14     $cookieDomain);
 15 

Upvotes: 1

Views: 694

Answers (1)

LIGHT
LIGHT

Reputation: 5712

try without cookie path and cookie domain

setcookie($cookieName,$cookieValue,$cookieExpire);

check if cookies are enabled in IE

============== EDIT ================

I think I got it, try this:

<?
$currentTime = time();
$cookieName   = "gohyde";
$cookieValue  = strval($currentTime);       // value is issue time (Unix Time)
$cookieExpire = strval($currentTime + 600); // expire is 10 minutes after issuing cookie 
setcookie($cookieName,
$cookieValue,
$cookieExpire);
echo $_COOKIE[$cookieName];
?>

without cookie path and cookie domain. and no "." dot in the cookie name.

Upvotes: 1

Related Questions