Print Page | Close Window

Public Cookies

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=6785
Printed Date: 29 March 2026 at 9:42am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Public Cookies
Posted By: Mc Brain
Subject: Public Cookies
Date Posted: 28 October 2003 at 1:05pm

I'm using these lines:

function tView(Value)
   { 
   if (Value) 
      document.cookie = "FullTreeView=True"; 
   else
      document.cookie = "FullTreeView=False";

   window.location.reload();
   }

To set or reset a cookie within an <a> tag. The question is... how do I get this cookie to work on all the pages of the site. It seems that a cookie on one page is different from "the same" cookie on another page. Am I clear?




Replies:
Posted By: Mart
Date Posted: 28 October 2003 at 1:35pm
Is this server side jscript or client side javascript?


Posted By: Mc Brain
Date Posted: 28 October 2003 at 1:57pm
client side... I think. It's executed whenever the user clicks on an <a> tag (on the compiled asp page)


Posted By: Mart
Date Posted: 28 October 2003 at 3:12pm
so why have you posted it in the asp section if its a clientside script?


Posted By: Mc Brain
Date Posted: 28 October 2003 at 3:19pm

Sorry... I didn't know where to post it. As a matter of fact, I'm not yet sure if it's clientside or not. I'm not that into this subjects.

Can you help me anyway? Or tell me where to post this question, please?



Posted By: KCWebMonkey
Date Posted: 28 October 2003 at 4:07pm
much easier if you learn about session variables in asp.

http://www.w3schools.com/asp/asp_sessions.asp - ASP Sessions



Posted By: Mc Brain
Date Posted: 28 October 2003 at 5:03pm
Not that much. I want this configuration to be saved in the user's computer. So that next time they get into these pages they can see the pages as they had chosen.


Posted By: dpyers
Date Posted: 30 October 2003 at 9:09pm
Go to the link provided by KCWebMonkey and look in the menu there for asp cookies.

-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Mc Brain
Date Posted: 30 October 2003 at 9:17pm
The examples on that page are in VBScript. I need them in Javascript since the cookie should be set or reset when the user clicks on a link (and then reload the page).


Posted By: MorningZ
Date Posted: 30 October 2003 at 9:35pm

not sure why you don't think you cannot set the cookie in VBScript then "reload" (using Response.Redirect) on the server side... i can guarentee you'll be using "the same cookies" then



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Mc Brain
Date Posted: 30 October 2003 at 9:37pm
That's how I was doing it... but  on pages that uses a form, the redirect does not work (because it looses all the form's information)


Posted By: MorningZ
Date Posted: 30 October 2003 at 9:48pm
umm. if you are having your users click on an <a> tag, you would be losing the form information anways, right?    unless you have some other javascript handling that part of it

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Mc Brain
Date Posted: 30 October 2003 at 9:53pm
Exactly... that's why I turned to Java. To change the cookie and do a "window.location.reload()" instead of a redirect. This way the form's informration is not missing. The problem is that it seems that these cookies are saved for this page and not for any otihers.


Posted By: dpyers
Date Posted: 30 October 2003 at 10:09pm
There's lots of good sample code for handling cookies, forms, redirection, etc. in javascript at http://developer.irt.org/script/script.htm - http://developer.irt.org/script/script.htm

-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Mc Brain
Date Posted: 31 October 2003 at 5:45am
This page http://developer.irt.org/script/1368.htm - http://developer.irt.org/script/1368.htm  states that the default path is "/". However, I cannot make it work. Any ideas how to solve this?


Posted By: MorningZ
Date Posted: 31 October 2003 at 6:26am

man, just figure out a way to pull it off in VBScript.. you could have had it done way by now.....

that way you are using apples and apples



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Mc Brain
Date Posted: 31 October 2003 at 6:36am

Is there anyway to get all the form's data? If that's so, I can create a form (on one of the common's page -header.asp, for example-) and set its action to open this page. Is there anyway I can get the whole form?



Posted By: Mc Brain
Date Posted: 31 October 2003 at 7:03am

Can someone explain this? I'm using this code:

FullTreeView = Request.Cookies.Item("FullTreeView")
If Len(FullTreeView) = 0 Then
    FullTreeView = False
End If

'This line is to save a VBScript cookie so that it should be accesible anywhere.
Response.Cookies("FullTreeView") = FullTreeView

It doesn't work. It keep treating each cookie as independent from one folder to another.

 



Posted By: dpyers
Date Posted: 31 October 2003 at 3:44pm
IIRC, one of the FAQ questions in that link I gave you talked about loosing cookies when traversing to a peer level directory. Cookies in the instance thay spoke off could be referenced by subordinate directories, but not equal directories. IIRC, their solution was to set the cookie in a page at the root level to make it accessible to all subordinate directories.

-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Mc Brain
Date Posted: 31 October 2003 at 9:07pm

The problem is that the default is the root folder. Anyway I tried to set the root folder (force it), but didn't work either.



Posted By: Mart
Date Posted: 01 November 2003 at 4:13am
Why dont you set the cookie in asp, because you can still access it through javascript there isnt a magic lock on it...


Posted By: Mc Brain
Date Posted: 01 November 2003 at 7:20am
What do you mean, Mart? What would you do?


Posted By: Mart
Date Posted: 01 November 2003 at 8:14am

You can set the cookie in vbscript and use javascript to do the thing when you click the link.

Mart.



Posted By: Mc Brain
Date Posted: 01 November 2003 at 8:18am

That's what I tried to do with these lines:

FullTreeView = Request.Cookies.Item("FullTreeView")
If Len(FullTreeView) = 0 Then
    FullTreeView = False
End If

'This line is to save a VBScript cookie so that it should be accesible anywhere.
Response.Cookies("FullTreeView") = FullTreeView

But didn't work.



Posted By: Semikolon
Date Posted: 02 November 2003 at 12:07pm
i suggest that you use vbscript and tell ppl not to write data into a for and then press a link before saving the data


Posted By: Mc Brain
Date Posted: 02 November 2003 at 8:10pm
Originally posted by AnthraX AnthraX wrote:

i suggest that you use vbscript and tell ppl not to write data into a for and then press a link before saving the data
Thanks, but that's not an option. It's a page for the whole corporation and cannot explain everybody what they should do or don't :(



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net