How to store cookies, so that a user would not need to store then next time.
I want to make an automation process for storing the cookies for now and for the next time user would access the website.
At the moment I found one example:
function readCookie(name)
{
var cookieValue = "";
var search = name + "";
if (document.cookie.lengt >0)
{
offset = document.cookie.indexOf(search);
if(offset != -1)
{
offset +=search.length;
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
cookieValue = unescape(document.cookie.substring(offset, end))
}
}
return cookieValue;
}
can someone explain what is happening here. As far as I know this only reads the data.
Any help would be much of appreciate.
There are typos in the example you show (lengt?). If you continue your search, you will probably find tons of examples on this topic, starting with this site…
To answer partially your question, most of the time the user doesn’t even know a cookie is stored, although I see a recent trend to ask permission to the user (is that a new legal obligation?).
Your question is a bit vague: you can get code to store and retrieve cookies, but you must call in some JavaScript on your site, know what to store, etc.