How to use Cookie with Magento?

Some time developer gets stuck with how to pass variable value from PHP to JavaScript (server side to client side). We can found a solution with cookie. Because cookie is the feature which is available at both side (PHP & JavaScript / Server side & Client side).

In Magento it has in-built JS library for cookie that his js\mage\cookies.js and for php side it has cookie model (core/cookie). So in magento we do not need to write core function for cookie.


How to use cookie in JS?

Set cookie value.


Get Cookie value


Delete Cookie / Cleare Cookie



How to use cookie with magento model?

Set Cookie value.


Get Cookie Value.


Delete Cookie







Leave a Reply