yeap just realized that. So far I've been using cookies but i ran across a few more problems.

This is part of my code from the button. Basically A means admin and B means employee.

If str1 = txt1 And str2 = txt2 And txt3 = "A" Then
Response.Cookies("ckusername").Value = 1
Response.Cookies("ckusername").Expires=DateTime.Now.AddDays(1)
Response.Redirect("admin.aspx")


ElseIf str1 = txt1 And str2 = txt2 And txt3 = "B" Then
Response.Cookies("ckusername").Value = 2
Response.Redirect("employee.aspx")
End If


I'm trying to get it so that it will only an admin to access a certain page or vise versa only if they got the correct value. On the admin page that I want employees to stay out I've added this code to the form load.

Dim objckusername As HttpCookie
objckusername = Request.Cookies("ckusername")
If objckusername.Value = 1 Then
//continue loading page

ElseIf objckusername.Value = 2 or objckusername.Value = NOTHING Then
Response.Redirect("main.aspx") //back to login page
End If


This code seems to be working fine after I log in as the employee and try to get into the admin page cause it kicks me back to the main page as it should cause i don't have the correct value in my cookie.

The problem right now is that say I choose to skip login and type the direct web address to say the admin page without logging in, instead of getting redirected back to main I get an error.

Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:


Line 42: Dim objckusername As HttpCookie
Line 43: objckusername = Request.Cookies("ckusername")
Line 44: If objckusername.Value = 1 Then
Line 45:
Line 46: