Current location: Hot Scripts Forums » General Web Coding » JavaScript » access cookie from different path


access cookie from different path

Reply
  #1 (permalink)  
Old 02-17-06, 03:06 AM
crmpicco's Avatar
crmpicco crmpicco is offline
Wannabe Coder
 
Join Date: Jan 2005
Posts: 124
Thanks: 0
Thanked 0 Times in 0 Posts
access cookie from different path

I set this cookie in a folder Inetpub/www/picco/asp
and within a file called net1.asp
Code:
function setOWCookie(NameOfCookie, value, expiredays)
{
	var url = location.href; // the current URL of the page (e.g. airbook.asp)
	var airbook = url.indexOf("air_book");
	var netfare3 = url.indexOf("net_fare3");

	// Three variables are used to set the new cookie.
	// The name of the cookie, the value to be stored,
	// and finally the number of days until the cookie expires.
	// The first lines in the function convert
	// the number of days to a valid date.
	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (expiredays * 24 * 3600 * 1000));
	
	// The next line stores the cookie, simply by assigning
	// the values to the "document.cookie" object.
	// Note the date is converted to Greenwich Mean time using
	// the "toGMTstring()" function.	
	document.cookie = NameOfCookie + "=" + escape(value) +
	((expiredays == null) ? "" : "; expires=" + ExpireDate.toGMTString()) + "domain=localhost";
	// If the current page is the airbook
	if(airbook!=-1)
	{
		var returning = document.getElementById("returning");
		returning.style.visibility="hidden";
		var returning_zelle = document.getElementById("returning_zelle");
		returning_zelle.style.visibility="hidden";
		var OpnJw = document.getElementById("OpnJw");
		OpnJw.style.display="none";				
	}
}
However, i want to access it in Inetpub/www/picco/asp/includes
and within a file called net1_include.asp

But this code below doesn't work, when trying to delete the cookie.
Code:
/*
FUNCTION NAME: delCookie
Deletes the cookie name that is passed to the function,
can be used for OJ and OW cookies
*/
function delCookie(NameOfCookie)
{
	// The function simply checks to see if the cookie is set.
	// If so, the expiration date is set to Jan. 1st 1970.
	if (retrieveCookie(NameOfCookie,"DEL"))
	{
		document.cookie = NameOfCookie + "=; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}
Any help appreciated.

Picco
Reply With Quote
  #2 (permalink)  
Old 02-21-06, 03:03 PM
TwoD TwoD is offline
Community VIP
 
Join Date: Sep 2003
Location: 404
Posts: 1,813
Thanks: 0
Thanked 0 Times in 0 Posts
I've tried to find information about this problem but haven't come up with a specific solution. Mostly because I can't figure out exactly why the cookie isn't accessible from both pages. The domain property should fix that problem.. have you tried setting it to your domain instead of localhost?
I'm afrain that I can't give a better answer, but maybe someone else can.
__________________
[W3Schools - learn all about the standards.] [QuirksMode - Browser Quirks] [MS's Online Reference Docs] [DOM in Gecko.]
Please pay attention to stickys, announcements and forum rules, thank you.
Please also remember Code Wrappers and [SOLVED] Marking, this helps everyone.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to find the full path of curent page? adrianTNT PHP 6 06-09-08 09:11 AM
maintaing state with a server Betty Perl 0 12-09-05 07:23 AM
getting the path to cgi-bin abtimoteo Perl 1 09-04-05 01:25 AM
Setting a cooke (time it expires) mcrob PHP 4 04-27-05 12:13 PM
Passing info between pages w/ URL HairySpider JavaScript 6 01-09-05 08:47 AM


All times are GMT -5. The time now is 11:03 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.