Created
January 18, 2013 19:50
-
-
Save kylekeesling/4567862 to your computer and use it in GitHub Desktop.
How to use the jQuery Cookie plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Example</title> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> | |
<!-- Available here: https://github.com/carhartl/jquery-cookie --> | |
<script src="jquery.cookie.js"></script> | |
</head> | |
<body> | |
<script> | |
// This sets your cookie | |
$(document).ready(function() { | |
$.cookie('nameOfMyCoolCookie', 'CookieValue', { expires: 7 }); //Expires in 7 days | |
}) | |
</script> | |
<script> | |
// This is how you use the cookie | |
$(document).ready(function() { | |
var myCookieValueInAVariable = $.cookie('nameOfMyCoolCookie'); | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment