I am using Jquery Cookie but am having difficulty setting and retrieving the info.
What I have so far is:
<script type="text/javascript" charset="utf-8" src="js/jquery.cookie.js"></script>
<script type="text/javascript">
$(function() {
var cookiedate = new Date();
cookiedate.setTime(cookiedate.getTime() + (60 * 60 * 1000));
$.cookie("mycookie", "checked", { expires: cookiedate, path: '/' });
console.log(cookiedate);
alert( $.cookie("mycookie") );
});
</script>
But it just isnt working.
Can anyone help me out to find out what I am doing wrong? Thanks!
jquery.Cookie handles the dates for you. Just feed it the number of days you want the cookie to be valid for:
P.S. Just in case you are using Chrome and are testing locally – Chrome doesnt support local cookies – Upload it to a server.