Vbscript check if Cookie exists

Hello,

I'm trying to show / hide elements based on  the existence of a cookie; I've tried using this -

<%if Not IsObject(Response.Cookies("user")) then %>
    <li><a href="#" rel="nofollow">Login</a></li>
    <li><a href="#" rel="nofollow">Register</a></li>
<%Else%>
    <li><a href="#" rel="nofollow">Account Settings</a></li>
<%End if%>

Open in new window


but no luck?

Any suggestions

Thank you
garethtnashAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontyWeb Ninja at largeCommented:
just check for a blank value:

<%if Response.Cookies("user") = ""  then %>
    <li><a href="#" rel="nofollow">Login</a></li>
    <li><a href="#" rel="nofollow">Register</a></li>
<%Else%>
    <li><a href="#" rel="nofollow">Account Settings</a></li>
<%End if%>

Open in new window

0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
You guys are very close.... off by one word.    You are looking for request.cookies, not response.cookies.  Response.cookies sets the cookie and request.cookies gets the cookie.  I know you knew that, probably just over looked.

FYI, you can request and set cookies via javascript/jquery if needed too.

Also,  it is a good idea to obfuscate the user cookie and create a token.  See my answer here that is very similar http:/Q_28641013.html
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
garethtnashAuthor Commented:
Hey Scott, can you provide that link again please.

Thank you
0
garethtnashAuthor Commented:
Tank you
0
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.