473,471 Members | 1,896 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Help With Accessing Cookies When Web Pages Are Located in Different Folders

Hi,

First I would like to state that I am not a JavaScript expert.

I have a simple shopping basket that uses cookies. The problem is that all
the product pages and basket must be in the the same folder.

I was wondering if it is possible to create and save a cookie so that it can
be accessed and viewed by HTML pages that are located in various different
folders?

Here is the code relating to the cookie:

document.cookie='TheBasket='+document.cookie.subst ring(countbegin,countend)+'['+newItem+'|'+newPrice+'|'+newTaxable+'|'+newURL+' |'+newQuantity+'];
expires= '+today+'';

index=document.cookie.indexOf('TheBasket');
Thanks,

Carl.

Feb 23 '06 #1
2 1187
Carl Read wrote:
First I would like to state that I am not a JavaScript expert.
That's great, there are quite a lot of people here that think they're
experts, all programmers should be modest :)

Here is the code relating to the cookie:
document.cookie='TheBasket='+document.cookie.subst ring(countbegin,countend)+'['+newItem+'|'+newPrice+'|'+newTaxable+'|'+newURL+' |'+newQuantity+'];
expires= '+today+'';

index=document.cookie.indexOf('TheBasket');


You can set a "path" property for the cookie, which specifies the
initial directory that will have access to the cookie, take a look here
<URL:http://php.net/set_cookie> and you'll understand.

I suggest you to use a cookie library, it's quite annoying to write it
manually =/

The first google result that I got
<URL:http://techpatterns.com/downloads/javascript_cookies.php>

Good luck =]
--
Jonas Raoni Soares Silva
http://www.jsfromhell.com
Feb 23 '06 #2
Thanks,

After playing around is seemed that once the path was set to the root
directory the cookies worked across folders.

document.cookie='TheBasket='+document.cookie.subst ring(countbegin,countend)+'['+newItem+'|'+newPrice+'|'+newTaxable+'|'+newURL+' |'+newQuantity+'];
path=/; expires= '+today+'';

Thanks for the help.

"Jonas Raoni" <jo********@gmail.com> wrote in message
news:dt**********@emma.aioe.org...
Carl Read wrote:
First I would like to state that I am not a JavaScript expert.


That's great, there are quite a lot of people here that think they're
experts, all programmers should be modest :)

Here is the code relating to the cookie:
document.cookie='TheBasket='+document.cookie.subst ring(countbegin,countend)+'['+newItem+'|'+newPrice+'|'+newTaxable+'|'+newURL+' |'+newQuantity+'];
expires= '+today+'';

index=document.cookie.indexOf('TheBasket');


You can set a "path" property for the cookie, which specifies the initial
directory that will have access to the cookie, take a look here
<URL:http://php.net/set_cookie> and you'll understand.

I suggest you to use a cookie library, it's quite annoying to write it
manually =/

The first google result that I got
<URL:http://techpatterns.com/downloads/javascript_cookies.php>

Good luck =]
--
Jonas Raoni Soares Silva
http://www.jsfromhell.com

Feb 24 '06 #3

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

Similar topics

2
by: paulp | last post by:
Greetings, I'm working on a CGI program that will run under MS IIS 5.0 and will browse folders on three other machines, building HTML pages that will provide links to these folders. ...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
10
by: Brian Conway | last post by:
I have no idea what is going on. I have a Login screen where someone types in their login information and this populates a datagrid based off of the login. Works great in debug and test through...
1
by: Thomas Scheiderich | last post by:
Just when you figure out one problem another one shows up. I am trying to set up authentication for one of my folders and can't seem to get it to work as advertised (I am sure I am missing...
2
by: Mark Fisher | last post by:
Hi all. I have read in several places that ASP.NET pages are compiled the first time they are run, and thefore run quicker the next time they are accessed. Is this true? If so, what are they...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
4
by: Joey | last post by:
asp.net 2/C#/VS2005 I have a web app where I use a stream writer to create a CSV (text) file. I then use my code to save the file in the site's 'App_Data' folder, in a subfolder called 'Temp'....
2
by: =?Utf-8?B?SnJ4dHVzZXIx?= | last post by:
I just started using Windows Live OneCare, I had been using Norton, but was unable to fix the problems I was having. I have yet been unsuccessful with OneCare as well. I keep getting the same...
7
by: cmrchs | last post by:
Hi, In Windows Vista: where does asp.net write its cookies? I use HttpCookie objCookie = new HttpCookie("nameCookie"); in Win2000 (and later) they used to be in C:\Documents and...
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
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,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
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.