Click to See Complete Forum and Search --> : Redirecting users


j.bird
02-02-2005, 09:57 AM
I am stumped here, I have pages in a protected directory that I don't want users to go to with out logging in first. The data is actually based on their log in profile. My problem is that when I go to a page that is suppose to be protected with out logging in I get an error that the variable is undefined. As it should be but I don't get redirected to the log-in page.

can any tell me what the proper syntax is for the following scenario.

user goes to a protected page without logging in
page should check for the existance of sessionID
If it is blank redirect user to the login page
If it is undefined redirect user to the login page

Here is the latest iteration of my code


sessionID = request.QueryString("sessionID")
If sessionID ="" then
response.Redirect("../login/login.asp")
end if


When coming to page from a bookmark the "sessionID" does not exist and the user should be redirect, but I get an error

any suggestions or examples would be greatly appreciated.

TIA

lmf232s
02-02-2005, 10:06 AM
I did not know if you reallly wanted to use a session variable or not
but this method is using a session("variable")

session("ID") = request.QueryString("sessionID")
If session("ID") = "" then
response.Redirect("../login/login.asp")
end if

and this method just uses a varialbe. Now if you have option explicit
at the top of your page and you do not declare your variable you
will get an error and your page will break before you can redirect
the user so you may need to declare you varible, which is not a bad
thing

Dim sessionID
sessionID = request.QueryString("sessionID")
If sessionID = "" then
response.Redirect("../login/login.asp")
end if

other then that your code works fine

j.bird
02-02-2005, 10:36 AM
Imf232s,

thanks for the info, DIM did the trick

Thanks again.

j bird