?
Solved

check if cookie exists in vb.net

Posted on 2009-07-03
2
Medium Priority
?
1,041 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 500 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

Understanding Linux Permissions

Linux for beginners: How to view the permissions associated with files and directories and also how you can change them.

Question has a verified solution.

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

IP addresses can be stored in a database in any of several ways.  These ways may vary based on the volume of the data.  I was dealing with quite a large amount of data for user authentication purpose, and needed a way to minimize the storage.   …
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

770 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