Skip to main content

Application::setCookie

Set COOKIE data

Description

public void Application::setCookie( string $name, string $value, [ string $expire = "" ], [ string $path = "/" ] )

Set COOKIE data.

Arguments

NameData typeDefaultRemarks
$namestringCookie param key
$valuestringValue
$expirestring""Expired time
$pathstringEnabled path

Example

If you omit third argument, expired time will be after 1 week (604800 seconds).

Controller
$this->setCookie('foo', 'bar');

You can set a expired time at 3rd argument.

Controller
// This Cookie's expired time is after 60 seconds.
$this->setCookie('foo', 'bar', 60);

You can set a Enabled path at 4th argument.

Controller
// This Cookie enable under the "/test/" path.
$this->setCookie('foo', 'bar', null, '/test/');