Solved

Checking if cookie exists - Error

Posted on 2014-07-30
3
190 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
  • 2
3 Comments
 
LVL 29

Accepted Solution

by:
Paul Jackson earned 500 total points
Comment Utility
 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
Comment Utility
Thanks Paul.  That code worked PERFECTLY!
0
 
LVL 29

Expert Comment

by:Paul Jackson
Comment Utility
No problem, glad to be of help.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

763 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now