Solved

Checking if cookie exists - Error

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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