Solved

Checking if cookie exists - Error

Posted on 2014-07-30
3
199 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
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

813 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

16 Experts available now in Live!

Get 1:1 Help Now