?
Solved

Checking if cookie exists - Error

Posted on 2014-07-30
3
Medium Priority
?
204 Views
Last Modified: 2014-07-30
I wrote an IF statement in order to check if the cookies exists.  If it does exist than it prints the user's name on the page, otherwise if it does not exist (in my case the cookie I'm checking for does NOT exist)  the user is redirected to the login page.

    Public Sub CheckCookie()
        If Not Request.Cookies("userInfo")("UserID") Is Nothing Then
            Call LoadUsersName()
        Else
            Response.Redirect("/Default.aspx")
        End If
    End Sub

Open in new window


When I load the page into a browser I'm getting the following error:

Cookie
Any idea what I could be doing wrong?
0
Comment
Question by:cdemott33
[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
3 Comments
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 2000 total points
ID: 40230826
 Public Sub CheckCookie()
        If Not Request.Cookies("userInfo") is Nothing Then
            If Not Request.Cookies("userInfo")("UserID") Is Nothing Then
                Call LoadUsersName()
            Else
                Response.Redirect("/Default.aspx")
            End If
        Else
            Response.Redirect("/Default.aspx") 
        End If
    End Sub

Open in new window

0
 

Author Closing Comment

by:cdemott33
ID: 40230858
Thanks Paul.  That code worked PERFECTLY!
0
 
LVL 29

Expert Comment

by:Paul Jackson
ID: 40230886
No problem, glad to be of help.
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses
Course of the Month13 days, 21 hours left to enroll

800 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