Solved

check if cookie exists in vb.net

Posted on 2009-07-03
2
979 Views
Last Modified: 2012-05-07
if I try to read a cookie (or session variable) that does not exist anymore I get a server error.
below an example of the code

if Request.Cookies("name of cookie") = "xyz" then
//some code
end if

a check like
- if Request.Cookies("name of cookie") = ""
- if Request.Cookies("name of cookie").length = 0
gives the same problem

is there a simple solution? in classic asp this was not an issue
0
Comment
Question by:reinoutkool
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 21

Accepted Solution

by:
Tapan Pattanaik earned 125 total points
ID: 24772875
0
 

Author Closing Comment

by:reinoutkool
ID: 31599576
this was the trick:
If Not Request.Cookies("UserSettings") Is Nothing Then
If Not Request.Cookies("UserSettings")("IsAdmin") Is Nothing Then
...
end if
end if
0

Featured Post

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question