Flourish PHP Unframework

fCookie

static class, v1.0.0b3

Provides a consistent cookie API, HTTPOnly compatibility with older PHP versions and default parameters

Changes:
1.0.0b3Added the delete() method 9/30/09
1.0.0b2Updated for new fCore API 2/16/09
1.0.0bThe initial implementation 9/1/08

Static Methods

::delete() public

Deletes a cookie - uses default parameters set by the other set methods of this class

Signature

void delete( string $name, string $path=NULL, string $domain=NULL, boolean $secure=NULL )

Parameters

string $name The cookie name to delete
string $path The path of the cookie to delete
string $domain The domain of the cookie to delete
boolean $secure If the cookie is a secure-only cookie

::get() public

Gets a cookie value from $_COOKIE, while allowing a default value to be provided

Signature

mixed get( string $name, mixed $default_value=NULL )

Parameters

string $name The name of the cookie to retrieve
mixed $default_value If there is no cookie with the name provided, return this value instead

Returns

The value

::reset() internal public

Please note: this method is public, however it is primarily intended for internal use by Flourish and will normally not be useful in site/application code

Resets the configuration of the class

Signature

void reset( )

::set() public

Sets a cookie to be sent back to the browser - uses default parameters set by the other set methods of this class

The following methods allow for setting default parameters for this method:

Signature

void set( string $name, mixed $value, string|integer $expires=NULL, string $path=NULL, string $domain=NULL, boolean $secure=NULL, boolean $httponly=NULL )

Parameters

string $name The name of the cookie to set
mixed $value The value of the cookie to set
string|integer $expires A relative string to be interpreted by strtotime() or an integer unix timestamp
string $path The path this cookie applies to
string $domain The domain this cookie applies to
boolean $secure If the cookie should only be transmitted over a secure connection
boolean $httponly If the cookie should only be readable by HTTP connection, not javascript

::setDefaultDomain() public

Sets the default domain to use for cookies

This value will be used when the $domain parameter of the set() method is not specified or is set to NULL.

Signature

void setDefaultDomain( string $domain )

Parameters

string $domain The default domain to use for cookies

::setDefaultExpires() public

Sets the default expiration date to use for cookies

This value will be used when the $expires parameter of the set() method is not specified or is set to NULL.

Signature

void setDefaultExpires( string|integer $expires )

Parameters

string|integer $expires The default expiration date to use for cookies

::setDefaultHTTPOnly() public

Sets the default httponly flag to use for cookies

This value will be used when the $httponly parameter of the set() method is not specified or is set to NULL.

Signature

void setDefaultHTTPOnly( boolean $httponly )

Parameters

boolean $httponly The default httponly flag to use for cookies

::setDefaultPath() public

Sets the default path to use for cookies

This value will be used when the $path parameter of the set() method is not specified or is set to NULL.

Signature

void setDefaultPath( string $path )

Parameters

string $path The default path to use for cookies

::setDefaultSecure() public

Sets the default secure flag to use for cookies

This value will be used when the $secure parameter of the set() method is not specified or is set to NULL.

Signature

void setDefaultSecure( boolean $secure )

Parameters

boolean $secure The default secure flag to use for cookies