473,791 Members | 2,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't set session cookie???

I'd like to set a session cookie that expires once the browser is
closed. I've tried:

document.cookie = "wm_javascript= " + escape("SomeNam e|" +
window.document .referrer);

with no expires. This doesn't set a cookie. It seems I must put in
an expiration for the cookie to set. The code below does work:

var the_name = window.document .referrer;
var the_cookie = "wm_javascript= " + escape("SomeNam e|" + the_name);
var the_date = new Date("December 31, 2050");
var the_cookie_date = the_date.toGMTS tring();
the_cookie = the_cookie + ";expires=" + the_date.toGMTS tring();
document.cookie = the_cookie;

Why doesn't the session cookie set? I'm using IE6.

Also, if a user has multiple IE windows open, will the session cookie
expires only after all IE windows have closed?

Thanks,
Brett
Jul 23 '05 #1
3 6392
Brett wrote:
document.cookie = "wm_javascript= " + escape("SomeNam e|" +
window.document .referrer);
with no expires. This doesn't set a cookie. It seems I must put in
an expiration for the cookie to set. The code below does work:

var the_name = window.document .referrer;
document.referr er is unreliable and using it is error-prone.
var the_cookie = "wm_javascript= " + escape("SomeNam e|" + the_name);
var the_date = new Date("December 31, 2050");
Using date strings is error-prone because interpretation is
implementation-dependent. Use several arguments instead:

var the_date = new Date(2050, 11, 31);
var the_cookie_date = the_date.toGMTS tring();
the_cookie = the_cookie + ";expires=" + the_date.toGMTS tring();
document.cookie = the_cookie;

Why doesn't the session cookie set? I'm using IE6.
Implementations usually follow the Netscape cookie specification:

<http://devedge.netscap e.com/library/manuals/2000/javascript/1.3/reference/cookies.html#10 02170>

Some UAs set cookies only if set by a resource retrieved via HTTP, thus
they do not set it with documents accessed with "file:" URIs, for example.
Some UAs consider cookies without "domain=" invalid and will not set those.
Also, if a user has multiple IE windows open, will the session cookie
expires only after all IE windows have closed?


Possibly.
PointedEars
Jul 23 '05 #2
In article <c0************ **************@ posting.google. com>,
ac*****@cygen.c om (Brett) wrote:
I'd like to set a session cookie that expires once the browser is
closed. I've tried:

Why doesn't the session cookie set? I'm using IE6.


I found it best to always set the date and time in IE. Figure out how
long you need to use the cookie and add a reasonable about of extra time
like an hour.

Has anyone gotten sessions cookies to work in IE: that is a cookie set
in IE without the date/time?

Robert
Jul 23 '05 #3
JRS: In article <41************ **@PointedEars. de>, dated Wed, 28 Jul
2004 05:00:01, seen in news:comp.lang. javascript, Thomas 'PointedEars'
Lahn <Po*********@nu rfuerspam.de> posted :
var the_cookie = "wm_javascript= " + escape("SomeNam e|" + the_name);
var the_date = new Date("December 31, 2050");


Using date strings is error-prone because interpretation is
implementati on-dependent. Use several arguments instead:

var the_date = new Date(2050, 11, 31);


Which browsers do not understand new Date("December 31, 2050"); ?

It is non-ISO numeric date strings that are unreliable; but "2050/12/31"
should be safe everywhere, and is understandable by anybody; whereas
some people think that December needs a Zed, or possibly a Zee, or
transpose letters in it.

In this case, "01/01/2051" could have been used.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
3378
by: Henry Hartley | last post by:
I've got a PHP system working on a development server (Windows 2000/IIS5/PHP 4.3.3) but it doesn't seem to be working quite right on the testing server (same except PHP 4.2.3). I upgraded the PHP on the testing server but that didn't seem to make any difference. One difference I noticed is that on the dev server, the session cookie is modified on EVERY page load. On the testing server the cookie gets created alright but it doesn't seem...
5
1976
by: Yossi | last post by:
I want to set the asp session id path property. how can I do that? I mean, asp session id is stored in a cookie and like any other cookie it should have properties (or attributes), how can I control it? Yossi.
1
3600
by: Jenn | last post by:
I have done alot of web work in all sorts of languages but I have never used the simple cookie. Question is How does one set and retrieve a simple session cookie. All it will do is have an image change on 1 page only with every new visitor, there are 5 images it should be random and stay the same unless the session is ended. Sounds pretty simple but I cannot find simple examples of a cookie doing anything similar to this. I found oodles...
1
3193
by: Steve Remer | last post by:
My application (relevant code snippets below) originally used Session variables in order to maintain state from page to page. After being unable to solve the mystery of why those variables were intermittently inaccessible, (all Session variables gone, not using InProc Session state mode), I moved to a cookies-based solution. Now I have cookie contents that are intermittently inaccessible. Someone suggested using session variables to...
4
2764
by: Chris | last post by:
When a request comes into a page on my ASP.net site and a session is not found, I want to detect whether the request is an initial request or if the user did have a session going that has now been lost and show an explanatory message before restarting the session. Rather than tagging a 'session in progress' flag on the end of every request querystring I'd like to detect it using data sent in every request. One idea I had was that when...
1
9322
by: Daniel Michaeloff | last post by:
Hi all, I have an application that when finished redirects to a non-ASP.NET app which is choking on a huge ASP.NET session cookie. The cookie "ASP.NET_SessionId" gets transmitted by the browser (IE6 in test case) despite trying Microsoft's suggested method of expiring the cookie first. I'd like to be able to kill the cookie and do a Response.Redirect() from within a server-side button handler, but I'm to the point now where I'm...
4
1701
by: Ibrahim. | last post by:
Hi, Kindly clarify the followings; 1. Is the session cookie & FormsAuthenticationTicket cookie Interdependent? 2. When a new SessionID is generated, I have noticed the Session Cookie and the FormsAuthentication cookie are binded. 3. I need to know whether it's possible by Code or settings to treat the
7
2242
by: Victor | last post by:
I've got two domain names sharing the same IP address that use ASP VBScript If I set a session variable with domain 1, it is only available for domain 1 - this is correct? If I set an application variable with domain 1, the app variable is sharing across all domains using that IP address - this is correct? This is the behavior I am seeing and I want to make sure that my server is set up correct. I especially want to make sure...
4
2875
by: rgparkins | last post by:
Hello I am running out of time with a problem I have running PHP 5.04 and Apache 2.0 and really need help :(. I have a page that stores a variable in session but each time I reload that page the session seems to be re-created and is an empty array. I have checked the session file and the variable is being stored against the session id, but I dont know why PHP is not picking up the session after I reload.. I have tried the usual suspects...
6
2283
by: =?Utf-8?B?S2VsbHk=?= | last post by:
We just switched our web application from .NET 1.1 to 2. Once client can't login out of several that have been successful. They enter a correct user name and password, click the login button and they are redirected back to login with no errors or login failure. The same login account works fine from other machines at different locations. This client had no problem logging in before we switched. The login procedures are essentially the...
0
10426
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10207
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10154
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9993
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5430
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5558
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4109
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3713
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.