Asf_Http_Cookie Asf_Http_Cookie::__construct(array $parameter)

Initialization Cookie

Notice: PHP setcookie don't recommended 'expire' set to 0, The effect is not the same across platforms.

The parameter format is as follows:

bool Asf_Http_Cookie::prefix(string $name)

Set the prefix 'name'

bool Asf_Http_Cookie::set(string $name, string $value [, int $expire])

Set cookie

bool Asf_Http_Cookie::forever(string $name, string $value)

Permanently save cookie

bool Asf_Http_Cookie::has(string $name)

Check a cookie

mixed Asf_Http_Cookie::get([string $name])

Get a cookie / if the parameter is empty, Get all cookies

bool Asf_Http_Cookie::del(string $name [, string $...])

Delete the specified cookies

bool Asf_Http_Cookie::clear(void)

Clear all cookies

Examples

Example #1

<?php
use Asf\Http\Cookie;

$cookie = new Cookie(['path' => '/', 'domain' => 'box3.cn', 'expire' => 3600, 'secure' => 1, 'httponly' => 1, 'prefix' => 'Asf_']);

print_r($cookie);

var_dump($cookie->has('a'));
var_dump($cookie->has(123));

var_dump($cookie->get('a'));
var_dump($cookie->get(123));
var_dump($cookie->get());

var_dump($cookie->set('a', 123456));
var_dump($cookie->set(123, 'string'));

var_dump($cookie->del('a', 123));
var_dump($cookie->clear());

var_dump($cookie->forever('a', 123456));
var_dump($cookie->forever(123, 'string'));