views:

34

answers:

1

How can we store dynamic variables into cookie . var username = ($("#username").val());

how to store the variable username into jquery cookie variable $.cookie('username', '+username +'); alert($.cookie('username'));

+1  A: 

If you put within a single quotes it takes only string.So for this you dont need the single quotes for assigning the value.
Try this

$(document).ready(function() { var username = ($("#username").val()); $.cookie('username',username ); alert($.cookie('username')); });
It is work out for me.

vinothkumar