Cookie Library



( ZN >= 0.0.1 )

A class that performs operations such as creating, using, and deleting cookies.

 

# Configuration


File:  ( ZN OE ) Config / Storage.php
Cookie
String $ encode = 'super' Used to encrypt cookie keys. If encryption is not requested, this value is left blank.
Options super , golden , md5 , sha1 ....
Bool $ regenerate = true Whether the session ID will be changed on page refresh.
scaler $ time = 604800 The life of the cookie.
String $ path = '/' Directory information for cookies to be kept.
String $ domain = '' Used to specify whether the cookie should be sent over a secure HTTPS connection to the client .
Bool $ secure = false Used to specify whether the cookie should be sent over a secure HTTPS connection to the client .
Bool $ httpOnly = true If TRUE , the cookie will onlybe accessible via theHTTPprotocol. This means that cookies will not be accessible by scripting languages ​​such as JavaScript.

 

# INI Configuration


File: Settings / Ini.php

The use of these settings is the same as described in the Session library.

 

# Methods


Bool insert ( String $ name , $ value , Int $ time = CONFIG_TIME )
Mixed select ( String $ name )
Array selectAll ( Void )
Bool delete ( String $ name , String $ path = CONFIG_PATH )
Bool deleteAll ( Void )
this time ( Int $ time )
this path ( String $ path )
this domain ( String $ domain )
this secure ( Bool $ secure )
this httpOnly ( Boolean $ httpOnly )
this encode ( String $ name , String $ value )
this decode ( String $ hash )

 

# Insert ( ZN >= 0.0.1 )


Used to create cookies.

Parameters

String $ name Cookie name.
Mixed $ Value The cookie's worth it.
scaler $ time = 604800 The life of the cookie.
return Bool

Use of

Cookie::insert('example', 'Example Data');

echo Cookie::select('example');
Example Data 

If desired, the sequence data can also be stored.

Cookie::insert('example', ['a', 1, 'b']);

output(Cookie::select('example'));
0 => string 'a' (length = 3 ) ,
1 => integer 1 (length = 1 ) ,
2 => string 'b' (length = 3 )

Direct Access ( ZN> = 5.2.0 )

Cookie::example('Example Data');

 

# Select ( ZN >= 0.0.1 )


Used to create cookies. If there is no session, the FALSEvalue returns.

Parameters

String $ name Cookie name.
return Mixed

Use of

Cookie::insert('example', 'Example Data');

echo Cookie::select('example');
Example Data 

Direct Access ( ZN> = 5.2.0 )

echo Cookie::example();

 

# SelectAll ( ZN >= 0.0.1 )


Used to get the values ​​of all cookies generated as an array.

Parameters

void
return Array

Use of

Cookie::insert('example', ['a', 1, 'b']);
Cookie::insert('value', 'Value');

output(Cookie::selectAll());
value => string 'value' (length = 7 ) ,
example => string "[" a "is 1," b "] (length = 13 ) ,
 

Direct Access ( ZN> = 5.2.0 )

output(Cookie::all());

 

# Delete ( ZN> = 0.0.1 )


Used to delete cookies created.

Parameters

String $ name Cookie name.
return Bool

Use of

Cookie::insert('example', 'Example Data');
Cookie::delete('example');
echo Cookie::select('example');
false 

Direct Access ( ZN> = 5.2.0 )

Cookie::exampleDelete();

 

# DeleteAll ( ZN >= 0.0.1 )


Used to delete all cookies created.

Parameters

void
return Bool

Use of

Cookie::insert('example', ['a', 1, 'b']);
Cookie::insert('value', 'Value');
Cookie::deleteAll();

output(Cookie::selectAll());
[]

 

# Time ( ZN >= 3.0.1 )


It is used to determine the lifespan of the cookie. It is an optional method. Used in place of parameter 3 of the Cookie :: insert () method .

Parameters

scaler $ Time The cookie's lifetime is specified in seconds.
return this

Use of

Cookie::time(60 * 60 * 24)->insert('oneDay', 'One Day');

 

# Time ( ZN >= 3.0.1 )


The cookie is used to identify the catch phrase. It is an optional method.

Parameters

String $ path In which order the cookie will be kept.
return this

Use of

Cookie::path('/cookies/')->time(60 * 60 * 24)->insert('example', 'Example Value');

 

# Domain ( ZN >= 3.0.1 )


It is used to specify which domain names the cookie will be valid for. It is an optional method.

Parameters

String $ domains The domain where cookies will be valid.
return this

Use of

Cookie::domain('example.com')
      ->path('/cookies/')
      ->time(60 * 60 * 24)
      ->insert('example', 'Example Value');

 

# Secure ( ZN> = 3.0.1 )


Used to specify whether the cookie should be sent over a secure HTTPS connection to the client . If TRUE is specified, the cookie will only be sent if a secure connection is available. It is an optional method.

Parameters

Bool $ Secure Safe mode.
return this

Use of

Cookie::secure(true)
      ->domain('example.com')
      ->path('/cookies/')
      ->time(60 * 60 * 24)
      ->insert('example', 'Example Value');

 

# Encode ( ZN >= 3.1.2 )


When creating a cookie you can use both the key to hold the value and the value itself to encrypt. Note that key cryptography can be solved while cryptography of value can not be solved . Predefined as Config / Services.php -> cookie settings by default in the encode key used to encrypt the setting md5 is set.

Parameters

String $ Encode Game Used to encrypt the key to hold the value of the cookie. If left blank, no encryption is made.
String $ Encodevalu to Used to encrypt cookie data. If left blank, no encryption is made.
return this

Use of

Cookie::encode('md5')->insert('sessionValue', 'Session Value');
Cookie::encode('sha1')->insert('sessionValue', 'Session Value');

\Output::writeLine(Cookie::decode('md5')->select('sessionValue'));
\Output::writeLine(Cookie::decode('sha1')->select('sessionValue'));
Session Value
Session Value 

 

# Decode ( ZN >= 3.1.2 )


Decrypts the cookie name encrypted with Cookie :: encode () . Encryption can not be resolved because it is done in one way for the value.

Parameters

String $ Encode Game Used to encrypt the key to hold the value of the cookie. If left blank, no encryption is made.
return this

Use of

Cookie::encode('md5')->insert('value', 'Cookie Value');

\Output::writeLine(Cookie::decode('md5')->select('value'));
Cookie Value 

The session value can also be encrypted if desired. However, it is not possible to resolve the data in this usage.

Cookie::encode('md5', 'sha1')->insert('value', 'Cookie Value');

\Output::writeLine(Cookie::decode('md5')->select('value'));
ed3f3e737cd0b4e396b1350e119a665b156e133 to