Javatpoint Logo
Javatpoint Logo

Phalcon Cookie Management

Cookie is a small text file stored by browser on user system. Cookies were designed to be a reliable mechanism for websites to remember stateful information or to record the user's browsing activity. Phalcon\Http\Response\Cookies is the directory where cookies are stored. Cookie management helps in storing cookies under the above directory during the request execution and is sent automatically at the end of the request.

Syntax:

To check previously set cookie: $var_name->cookies->has('checking_name');

Get the cookie: $var_name->cookies->get('cookie_name');

Get cookie value: $var_name->cookies->getValue();

Set the cookie: $var_name ->cookies->set(cookie_name, 'some value', time() + 15 * 86400);

Delete the cookie: $var_name ->cookies->get('cookie_name ')->delete();


Example of Cookie generation

On above code execution following files are generated

Phalcon Cookie 1

Now implement and generate cookie from following code: In this cookie name is "login-action" with value "javatpoint".

Output

Phalcon Cookie 2

Encryption/Decryption of Cookies

Cookies contain the important information about the user browsing that's why by default it is encrypted. It is encrypted when sent to client and decrypted when retrieved by the user.

To disable the encryption we can do following changes in the code:


Next TopicPhalcon Request





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA