:::: MENU ::::

Prestashop session and cookies

Prestashop session and cookies

Today we talk about how to use Prestashop session and cookies. The first thing you must know Prestashop did not use the session it is using the cookie for storing the data So let talk about the cookies. In this tutorial, we focus on set cookies, get cookies, and unset the cookies. So let’s start it.

You can get the cookie variable by following.

in the Controller file.

 $cookieObject = $this->context->cookie;

Other files

 $cookieObject = Context::getContext()->cookie;

Set Cookies

     $context->cookie->__set('simplaedata', 'abc');

To store an array in cookies you need to serialize data. an example is below.

     $array = array('a','b','c');
     $context->cookie->__set('simplaedata', serialize($array));

Get Cookies


UnSet Cookies

Author: Qaisar Satti
Category: Prestashop
Last Modified: October 12, 2020

So, what do you think ?

You must be logged in to post a comment.