jaypoc's Avatar
jaypoc 3
5 Asked
31 Answered
11 Best
0
No one has voted on this question yet :(
2 years, 11 months ago

How do you access JavaScript cookies from ASP?

I am working on a site that was written in ASP (VBScript) and added a Javascript/CSS based "disclaimer" that i want to show up the first time site is loaded after logging in.

The way the script works is that if there is no cookie named "droppedin" then it sets one and displays the disclaimer as an animated/fly-in window.

I want the logout page (logout.asp) to clear this cookie. I have tried the following:

Response.Buffer = true
Response.CacheControl = "no-cache"
Response.AddHeader "Pragma", "no-cache"
Response.Expires = -1
Server.ScriptTimeout = 60

Session("uid") = ""
Session("pass") = ""
Session("group") = ""
Session("shift") = ""
Session("UserAuth") = ""
Session("UserAdmin") = ""
Response.Cookies("droppedin") = ""
Response.Redirect("login.asp")

This does not clear the cookie. Using TamperData in Firefox, the cookie values show as follows (note 2 droppedin cookies):

Cookie=droppedin=yes; droppedin=; ASPSESSIONIDCCACSRDS=GDNPECNDBANFJKFAAOLOMMDI

How can I access a cookie set by JavaScript and re-set it from ASP/VBScript?
Tip for best answer: M$1.00
Separate topics with commas, or by pressing return. Use the delete or backspace key to edit or remove existing topics.

You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.

M$

What is Your Answer?

0
0
0

3 Answers

0
timcadieux's Avatar
timcadieux | 2 years, 11 months ago
4
At Logout.asp you could tell the cookie to Expire immediately, using

response.cookies("droppedin").expires=now

this essentially 'destroys' the cookie.

You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.

M$
jaypoc's Avatar
jaypoc | 2 years, 11 months ago Report

The issue is it's not overriding the initial cookie. It's creating a separate cookie with the same name. The Javascript sets it's own cookie and the ASP code sets another one. I want them to overwrite/share the cookie, or be able to change the variable.

That would expire the "ASP" cookie, but not the JavaScript cookie.

Report Abuse

Post Reply Cancel
1
serversupport's Avatar
serversupport | 2 years, 11 months ago
3

You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.

M$
jaypoc's Avatar
jaypoc | 2 years, 11 months ago Report

This introduces a possible workaround, by passing the Javascript and ASP calls back and forth through page requests. Not the best solution, but the best so far. If Mahalo didn't give the other response Best Answer already, I'd give it to you as the other response suffers the same issue I've been having

Report Abuse

Post Reply Cancel
0
pabloperez's Avatar
pabloperez | 2 years, 11 months ago
0
Request object

You can leave an optional "tip" with Mahalo's virtual currency, Mahalo Dollars. If you are asking a difficult question that might require some research, or if you'd like a wide variety of feedback, a higher tip often leads to more answers to your question.

M$

Report Abuse

Post Reply Cancel

Learn something new with our FREE educational apps!

Private lessons in the comfort of your own home. Get back in shape or finally pick up a guitar with our great experts guiding you the whole way!
Learn Guitar
Learn Hip Hop
Learn Pilates