i-mode-emulator.com
English Francais Deutsch

Notes about the Set-Cookie Header

1. The i-mode platform does not support Set-Cookie2 (RFC 2965)
The i-mode platform supports the cookie specification RFC 2109 which was originally invented as a de fac-to standard by netscape. According to RFC 2109 the i-mode platform supports the "Set-Cookie" Header. When the "Set-Cookie" Header is set by the CP the i-mode platform stores the transmitted cookies in the i-mode cookie store and removes the "Set-Cookie" Header from the HTTP Response. This means that the User-Agent (i-mode handset) never gets any cookies. Currently available User-Agents (N21i, TS21i) do not support cookies anyways.

The newer Cookie specification within RFC 2965 is not supported by the i-mode platform. Therefor the "Set-Cookie2" Header is not supported by the i-mode platform. When the CP uses the "Set-Cookie2" Hea-der, this header field will be ignored by the i-mode platform and will be forwarded to the i-mode handset like any other header field.

2. The PHP function setcookie does not work with i-mode
The PHP setcookie function it is not compatible with the Cookie specification (RFC2109) and some Web browsers. It is also not compatible with the i-mode platform. Most PHP versions (including 4.x) generate a Set-Cookie header with a 2 digit year in the expiration date. The i-mode platform supports only a 4 digit ye-ar or the newer "max-age" instead of "expires".
If you use PHP4 and if you can not read the cookie then use this function to SET the cookie instead of the built-in function:
function imode_setcookie($name,$value,$maxage,$path="",$domain="",$secure="")
{
 $s = "$name=";
 if ($value) $s .= urlencode($value);
 $maxage = $maxage - time();
 if ($maxage < 0) $maxage = 0;
 $s .= "; max-age=$maxage";
 if ($path) $s .= "; path=$path";
 if ($domain) $s .= "; domain=$domain";
 if ($secure) $s .= "; secure=$secure";
 header("Set-Cookie: $s");
}
Example:
 imode_setcookie("name1", "value1", mktime(0,0,0,2,1,2005), "/");
Please use this function also to remove Cookies:
 imode_setcookie("name1", "", 0, "/");