Click here to Skip to main content
15,893,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

The code is
C#
ec.get("id", function(value) { alert("Cookie value is " + value) });


How do I store the cookie value in variable "val"?
Posted

I guess following would work.
JavaScript
var val = value;


[Edit]

JavaScript
ec.get("id", function(value) { var val = value; alert("Cookie value is " + value) });
 
Share this answer
 
v2
Comments
FahdSanaullah 14-Jan-14 6:26am    
Please elaborate?
I have updated the answer. :) Is that what you need?
In case you need something else, please reply with your query.
FahdSanaullah 14-Jan-14 10:20am    
That's great. If you could just please tell me how to be able avail this variable after this function, how do I do it?
Like I write this:

ec.get("id", function(value) { var val = value; });
alert("Cookie value is " + val);

But it doesn't work :/
For that you have to change its scope to Global. Declare it outside the function like...

var val;

ec.get("id", function(value) { val = value; });
alert("Cookie value is " + val);
FahdSanaullah 14-Jan-14 10:30am    
I appreciate your help, but now the alert box says "Cookie value is undefined" which means it's not working :(
Hello FahdSanaullah,

$(document).ready(function() { var val = ($("#value").val()); $.cookie('value',value ); alert($.cookie('value')); });


I guess this code will help you out to store the cookie value in variable "val".
 
Share this answer
 
Comments
FahdSanaullah 14-Jan-14 6:25am    
Nope :/
Its evercookie. Not working.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900