jquery - How to Store More then one data in cookie in Json using Javascript -
what need
i need store max of 3 events id in json string.
like: { 9,133,34}.
next want when 4 th event id insert override 9 event id . , 5th override 133 , on.
scenario when user land on page of event id stored in cookie. in json string, , on user browser browser browse next event id gets stored in json string , max limit of 3 events id storing.
i have reffer note : howe can save more strings in cookie , place them in list?
i have tried like
html
<input type=hidden id="eventid" value="{{ data.detailes.data.event.event_id }}"> <input type=hidden id="industry_id" value="{{data.detailes.data.industry_id.id}}">
js code
var cookie_event_id=document.getelementbyid("eventid").value; alert(cookie_event_id); document.cookie = 'event_id=' + cookie_event_id; var cookie_industry_id=document.getelementbyid("industry_id").value; alert(cookie_event_id); document.cookie = 'industry_id=' + cookie_industry_id;
i have tried
var cookie_event_id=document.getelementbyid("eventid").value; var cookieevent = [event_id, '=', json.stringify(cookie_event_id), '; domain=.', window.location.host.tostring(), '; path=/;'].join(''); document.cookie = 'event_id=' + cookieevent;
step 1 . store browser ids 1 array.
store 2. fetch ids , store cookie.
code
var arr = []; // append new value array arr.push(cookie_event_id); console.log(ids.tostring()); document.cookie = 'event_id=' + arr;
snapshot cookie browser
lastly after googling lot tried not working
var arr[]; document.cookie = 'event_id=' + serializearray().map(function(x){arr[x.eventid] = x.value;
document.cookie="name=sample; expires=thu, 18 dec 2015 12:00:00 utc; path=/";
keyword: document.cookie expires: not must automatically reset cookie
Comments
Post a Comment