Link to home
Start Free TrialLog in
Avatar of reinoutkool
reinoutkoolFlag for Netherlands

asked on

check if cookie exists in vb.net

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
ASKER CERTIFIED SOLUTION
Avatar of Tapan Pattanaik
Tapan Pattanaik
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of reinoutkool

ASKER

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