making jquery cookies persistent
Hi,
I'm trying to use jquery to do some things. It works well, but I can't seem to get it to set a cookie that doesn't expire when I end the browser session.
The books and examples say this should work:
- function CheckPW(){
var PWDiv = document.getElementById("PWDiv");
var Uname = document.getElementById("UserName");
var Pword = document.getElementById("PassWord");
var MyUser=Uname.value;
var MyUN=Uname.value;
var MyPW=Pword.value;
for (var x in User) {
//PWDiv.innerHTML += x + " " + User[x] + "<br>";
if(MyUN == x) {
if(MyPW == User[x]){
//var logcookie = $.cookies.get("PWCookie"); Do I really need this line?
PWDiv.innerHTML += " Logged In as " + x + "<br>";
$.cookies.set("PWCookie", x, {expires: 15});
}
} else {
//PWDiv.innerHTML += "Oh, well... <br>";
}
}
}
function LogInit(){
logcookie = $.cookies.get("PWCookie");
var Uname = document.getElementById("UserName");
//alert(logcookie);
Uname.value = logcookie;
}
Firefox(v3.6.3), IE8, and Google Chrome all reload the cookie as long as I have not closed the session.
When I close the browser, the cookie disappears.
One other thing... the web page and scripts are contained in a folder on my local machine. Do these have to be on a server (a bona fide web server) to work?
Any Thoughts???
Sincerely,
Ken