Rapodo
11-17-2014, 11:10 PM
Can anyone help me turn this cookie into a persistent cookie until its time-to-live has elapsed?
Also IE will only persist a cookie if it has an Expires date.
Session cookies, held in memory, and which expire once the browser exits. Persistent cookies, which have a time-to-live, are persisted on disk, and are sent by the browser until their time-to-live has elapsed. I am needing a persistent cookie to stay after the browser has closed so the background image stays the same that the user has selected. Can anyone please help with this? I will be very thankful!
<html>
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<!--download jquery.cookie from here http://plugins.jquery.com/cookie -->
<script type="text/javascript" src="images/jquery.cookie.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var theme = $.cookie("backgroundImage");
if (theme){document.getElementById("shelf").style.backgroundImage = "url("+theme+")";}
$("#themes").change(function() {
theme = $(this).val();
$.cookie("backgroundImage", theme);
document.getElementById("shelf").style.backgroundImage = "url("+theme+")";
});
});
</script>
</head>
<body id="shelf">
<!--<select id="themes" onChange="changeTheme()" name="ChangeBG">-->
<select id="themes" name="ChangeBG">
<option value="images/background1.jpg" selected="selected">Default</option>
<option value="images/background2.jpg">name</option>
<option value="images/background3.jpg">name</option>
<option value="images/background4.jpg">name</option>
<option value="images/background5.jpg">name</option>
</select>
</body>
</html>
Also IE will only persist a cookie if it has an Expires date.
Session cookies, held in memory, and which expire once the browser exits. Persistent cookies, which have a time-to-live, are persisted on disk, and are sent by the browser until their time-to-live has elapsed. I am needing a persistent cookie to stay after the browser has closed so the background image stays the same that the user has selected. Can anyone please help with this? I will be very thankful!
<html>
<head>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<!--download jquery.cookie from here http://plugins.jquery.com/cookie -->
<script type="text/javascript" src="images/jquery.cookie.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var theme = $.cookie("backgroundImage");
if (theme){document.getElementById("shelf").style.backgroundImage = "url("+theme+")";}
$("#themes").change(function() {
theme = $(this).val();
$.cookie("backgroundImage", theme);
document.getElementById("shelf").style.backgroundImage = "url("+theme+")";
});
});
</script>
</head>
<body id="shelf">
<!--<select id="themes" onChange="changeTheme()" name="ChangeBG">-->
<select id="themes" name="ChangeBG">
<option value="images/background1.jpg" selected="selected">Default</option>
<option value="images/background2.jpg">name</option>
<option value="images/background3.jpg">name</option>
<option value="images/background4.jpg">name</option>
<option value="images/background5.jpg">name</option>
</select>
</body>
</html>