473,394 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Cookies don't survive browser close...

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:

Expand|Select|Wrap|Line Numbers
  1.         function CheckPW(){
  2.  
  3.  
  4.             var PWDiv = document.getElementById("PWDiv");
  5.             var Uname = document.getElementById("UserName");
  6.             var Pword = document.getElementById("PassWord");
  7.  
  8.             var MyUser=Uname.value;
  9.             var MyUN=Uname.value;
  10.             var MyPW=Pword.value;
  11.             for (var x in User) {
  12.                 //PWDiv.innerHTML += x + " " + User[x] + "<br>";
  13.                 if(MyUN == x) {
  14.                     if(MyPW == User[x]){
  15.  
  16.                         PWDiv.innerHTML += " Logged In as " + x + "<br>";
  17.                         $.cookies.set("PWCookie", x, {expires: 15});
  18.  
  19.                     }
  20.                 } else {
  21.                     //PWDiv.innerHTML += "Oh, well... <br>";
  22.                 }
  23.  
  24.             }
  25.         }
  26.  
  27.             function LogInit(){
  28.                 logcookie = $.cookies.get("PWCookie");
  29.                 var Uname = document.getElementById("UserName");
  30.                 //alert(logcookie);
  31.                 Uname.value = logcookie;
  32.  
  33.                             }
  34.  
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
Apr 26 '10 #1
3 1647
acoder
16,027 Expert Mod 8TB
How are you accessing the page? Using localhost or 127.0.0.1 or similar or via file:// ?
Apr 29 '10 #2
I'm accessing on my development machine by double clicking the html... so I suppose it is by *file:// -- but it does the same when I put the files on my website, and also when I have a friend try it from his computer.

Ken
Apr 29 '10 #3
In Fact...

http://www.elvehjem.com/MissMap/MissMap.html is the site,

and you can try these 2 U/N / P/W combinations, if you would be so kind!

"Red Rider" : "Trigger",
"Easy Rider" : "Harley"

Thanks!

Ken
Apr 29 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

20
by: Brian Burgess | last post by:
Hi all, Anyone know if this is possible? If so, on which page would the cookie be? .. On the page calling a function defined in the include file? thanks in advance.. -BB
2
by: Amit D.Shinde | last post by:
Hello Experts.. I need some help regarding cookies and session objects and also global.asa file I am creating one cookie when a user logs in on my website. The cookie stores the login name of...
5
by: anony | last post by:
Hi, I have a site that uses forms authentication to secure the directory. The site behaves as expected when viewed externally... if I close the browser and attempt to access it again, I get...
1
by: Joe Fallon | last post by:
I use forms authentication for my app. After I log in successfully each request by the browser contains 2 cookies. One for the SessionID and one for forms authentication which contains my ticket....
3
by: Raghu Raman | last post by:
Hi, I want to store a cookie peemanently for 2 days.From msdn article, i have coded like this.It is working when i run my application .But if i close my browser and restart my application , i...
7
by: Marcus | last post by:
I know that when you start a session in PHP, the "cookie" it creates is not the same as those that are stored in your browser's temp folder, and instead is kept in RAM. I am confused because in...
3
by: Phillip N Rounds | last post by:
I'm having trouble with using cookies to monitor the stages of login. I have a two stage Registration page ( register.aspx ) and my target page ( MyPage.aspx ) I'm using a cookie named LoginStatus...
3
by: johnny | last post by:
hi all! I am starting to study the best way to track site visitors. Logfiles stats which come with every web hosting, have little metrics to be analyzed and also problems with cached pages which...
4
by: surf_doggie | last post by:
I found that a number of my sites that send email using CDO failed withing the past 30 days. Consider the following. I know its not the best coding practice to open and close the connection so many...
3
by: Matthew Laping | last post by:
I'm in the process of creating a web farm, however my cookie information is not seen by both servers. I'm thinking it might be a security issue because my web farm is not fully functional....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.