Organizational Research By

Surprising Reserch Topic

How to set/unset cookie with jQuery?


How to set a cookie named 'test' and value '1'?

And especially, how to unset?

asked May 20, 2015 in JAVASCRIPT by rahulgii
0 votes
22 views



Related Hot Questions



Government Jobs Opening


You can set the cookies as like

setCookie('test','1');
You can get the cookies as like

getCookie('test');
Hope it will helps to someone :)

EDIT:

If you want to save path of cookie for homepage alone then do this like

function setCookie(key, value) {
                var expires = new Date();
                expires.setTime(expires.getTime() + (1 * 24 * 60 * 60 * 1000));
                document.cookie = key + '=' + value +';path=/'+ ';expires=' + expires.toUTCString();
            }
answered May 20, 2015 by rahulgii

...