cookies in Javascript and ASP
am 27.08.2007 21:01:33 von tanya.wang
Hi all,
I wanna create a new notes reminder system in my website. Everytime
when a user logs in he would receive a small piece of alert. He will
kept receiving it until he either logoff or "chooses to close it".
Once it's closed, the alert is turned off. So I embeded this piece of
my program in a header file that would be called by every of my
webpage myheader.asp
In myheader.asp I called another program mynotice.asp to see if a user
will receive a small alert of new notice. Once he chooses not to
receive, a cookie will be set and the alert will never be loaded.
Here is what I put in myheader.asp... the request.cookies("isLogin")
was set by ASP when the user is logged in.
<% if request.cookies("isLogin")="OK" and
request.Cookies("readNotice")<>"1" then %>
<% end if %>
Here is what I do in mynotice.asp
onclick="ClosePopup()"> |
Here comes my question -
My asp pages cannot tell the request.Cookies("readNotice") which was
set up by javascript. If I triggered the closePopup(), and switch to
another page, it will still run into the mynotice.asp unless I refresh
my current page.
But what I really want is to remember if a user has clicked the
closePopup() during his login. If so then turn off the alert. When he
log off this cookie things should be cleared.
Could anyone tell me why my cookies cannot be read by asp? Or should I
abort using cookie for this function and use something else instead?
Re: cookies in Javascript and ASP
am 01.09.2007 17:47:20 von Anthony Jones
wrote in message
news:1188241293.663828.321890@d55g2000hsg.googlegroups.com.. .
> Hi all,
>
> I wanna create a new notes reminder system in my website. Everytime
> when a user logs in he would receive a small piece of alert. He will
> kept receiving it until he either logoff or "chooses to close it".
> Once it's closed, the alert is turned off. So I embeded this piece of
> my program in a header file that would be called by every of my
> webpage myheader.asp
>
>
>
> In myheader.asp I called another program mynotice.asp to see if a user
> will receive a small alert of new notice. Once he chooses not to
> receive, a cookie will be set and the alert will never be loaded.
>
> Here is what I put in myheader.asp... the request.cookies("isLogin")
> was set by ASP when the user is logged in.
>
> <% if request.cookies("isLogin")="OK" and
> request.Cookies("readNotice")<>"1" then %>
>
> <% end if %>
>
> Here is what I do in mynotice.asp
>
>
>
>
> onclick="ClosePopup()"> |
>
>
>
>
>
>
> Here comes my question -
> My asp pages cannot tell the request.Cookies("readNotice") which was
> set up by javascript. If I triggered the closePopup(), and switch to
> another page, it will still run into the mynotice.asp unless I refresh
> my current page.
> But what I really want is to remember if a user has clicked the
> closePopup() during his login. If so then turn off the alert. When he
> log off this cookie things should be cleared.
>
> Could anyone tell me why my cookies cannot be read by asp? Or should I
> abort using cookie for this function and use something else instead?
>
Have you considered using a session variable?
Also consider ditching the annoying popup and replace it with something more
subtle such as a 'New Notice' icon in the header bar on the page(s).
--
Anthony Jones - MVP ASP/ASP.NET