tags:

views:

18

answers:

2

Hi, I have created Cookie in CGI page and tried to clear in PHP page.

CGI source:

Set-Cookie: cookieName="value"; path=/;\n

PHP source:

setcookie ("cookieName", "", time() - 3600);
unset($_COOKIE['cookieName']);

Have an idea? Please help.

Thanks

A: 

the name of your cookie is value , as shown in your code

setcookie ("value", "", time() - 3600); unset($_COOKIE['value']);

Grumpy
A: 

Hi, I found the solution.

In CGI, every time get cookies from the following

$env{'CookieName'}

To clear in PHP, I tried the following coding

// unset cookies
if (isset($_SERVER['HTTP_COOKIE'])) {
    $cookies = explode(';', $_SERVER['HTTP_COOKIE']);
    foreach($cookies as $cookie) {
        $parts = explode('=', $cookie);
        $name = trim($parts[0]);
        setcookie($name, '', time()-1000);
        setcookie($name, '', time()-1000, '/');
    }
}

Thanks to all

gnabhan