Mokoala v4.0

§ Basic Guides » Cookies

The MK_Cookie class functions in a similar fashion to the MK_Session class. You start the object using MK_Cookie::start() as shown below.

$config = MK_Config::getInstance();

MK_Cookie::start( $config->site->base, ( $config->server->local == true ? false : $config->server->name ) );

$cookie = MK_Cookie::getInstance();

$cookie->set('my_value', 'some text', 10);

The parameters are the folder path and site url, to which the cookie will be bound. For simplicity we pull this data from the MK_Config class, which stores site configuration data.

In the below example you can see how cookie data is stored.

$config = MK_Config::getInstance();

MK_Cookie::start( $config->site->base, ( $config->server->local == true ? false : $config->server->name ) );

$cookie = MK_Cookie::getInstance();

$cookie->set('my_value', 'some text', 1000);

This would basically store the text 'some text' to $_COOKIE['my_value'] value.

You can then access this variable using $cookie->my_value, as shown below.

$config = MK_Config::getInstance();

MK_Cookie::start( $config->site->base, ( $config->server->local == true ? false : $config->server->name ) );

$cookie = MK_Cookie::getInstance();

print $cookie->my_value;

Cookies can be deleted using unset(), as shown below.

$config = MK_Config::getInstance();

MK_Cookie::start( $config->site->base, ( $config->server->local == true ? false : $config->server->name ) );

$cookie = MK_Cookie::getInstance();

unset($cookie->my_value);

Authenticating Users

Basic Guides

Handling Forms

Social Sign In

Using the Dashboard

Working With Data

levitra online