Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Help With Accessing Cookies When Web Pages Are Located in Different Folders

Reply
Thread Tools

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

 
 
Carl Read
Guest
Posts: n/a
 
      02-23-2006
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.



 
Reply With Quote
 
 
 
 
Jonas Raoni
Guest
Posts: n/a
 
      02-23-2006
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
 
Reply With Quote
 
 
 
 
Carl Read
Guest
Posts: n/a
 
      02-24-2006
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" <(E-Mail Removed)> wrote in message
news:dtkppm$846$(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to read some information located on different page Pasha Javascript 7 06-10-2009 02:25 AM
Give Request.Cookies and Response.Cookies is there any reason to use another method to use cookies? _Who ASP .Net 7 09-18-2008 07:49 PM
connection between database & website located at different places sravan_reddy001 ASP .Net 6 05-19-2008 04:32 AM
accessing a file from DLL that's located in Bin directory Joo Park ASP .Net 1 02-18-2005 10:42 PM
Creating cookies in Global.asa Session_OnStart but cannot read cookies on subsequent pages. bb ASP General 0 09-15-2004 09:56 PM



Advertisments