Solved

Checking if cookie exists - Error

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

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…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

696 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