\PhalApi_Cookie

Cookie Operation

  • simple wrapper fo PHP original COOKIE
  • NOTE: the new cookie will works in next request time


Usage:

 // COOKIE
 DI()->cookie = 'PhalApi_Cookie';

 // set COOKIE
 DI()->cookie->set('name', 'phalapi', $_SERVER['REQUEST_TIME'] + 600);

 // get COOKIE
 echo DI()->cookie->get('name');  // output phalapi

 // delete COOKIE
 DI()->cookie->delete('name');

Summary

Methods
Properties
Constants
__construct()
get()
set()
delete()
getConfig()
No public properties found
No constants found
No protected methods found
$config
N/A
No private methods found
No private properties found
N/A

Properties

$config

$config : 

COOKIE configuration

Type

Methods

__construct()

__construct(  $config = array()) 

Parameters

$config

get()

get(string  $name = NULL) : \string/NULL/array

Get COOKIE

Parameters

string $name

COOKIE name

Returns

\string/NULL/array —

return the whole $_COOKIE when $name is NUL; return cookie value when exists, or NULL when not exists

set()

set(string  $name, \string/int  $value, integer  $expire = NULL) 

Set COOKIE

Parameters

string $name

COOKIE name

\string/int $value

COOKIE value, suggest to be some simple strings or number, not sensitive data

integer $expire

expire timestamp, expire in one MONTH when $expire is NULL

delete()

delete(\strint  $name) 

Delete COOKIE

Parameters

\strint $name

COOKIE name

getConfig()

getConfig() 

Get COOKIE config