Logging off from a website

G

Geoff Wickens

I am amazed at how much help I have had in creating my first asp based
website from this forum. There are obviously a significant number of real
experts who are happy to take the time to help us novices. My site which now
does what it aims to would not be working without this assistance and I am
extremely grateful. Long may it continue!!!!!

My next problem is as below:

I have created a website where various categories of users can log on to get
at secure pages. I do this by checking usernames and passwords against a
list in a database and set session("loginadmin")=true or
session("loginctte")=true depending on what category is stored in my
database. On the secure pages I now want to put a log off button and am
interested to know what code I need.

Currently I have created a form and this calls a page (logouthandler.asp).
The code on this page is

<%
session("loginadmin")=false
session("loginctte")=false
response.redirect ("../index.asp")

%>

Does this do anything worthwile and is anything else recommended?

Geoff Wickens
 
K

Ken Schaefer

You can do that. However, if you end up having a large number of session
variables, then your code will become cumbersome to write. You could do:

<%
Session.Abandon
Response.Redirect(...)
%>

Cheers
Ken


....
: I have created a website where various categories of users can log on to
get
: at secure pages. I do this by checking usernames and passwords against a
: list in a database and set session("loginadmin")=true or
: session("loginctte")=true depending on what category is stored in my
: database. On the secure pages I now want to put a log off button and am
: interested to know what code I need.
:
: Currently I have created a form and this calls a page (logouthandler.asp).
: The code on this page is
:
: <%
: session("loginadmin")=false
: session("loginctte")=false
: response.redirect ("../index.asp")
:
: %>
:
: Does this do anything worthwile and is anything else recommended?
 
D

Dan Brussee

I have created a website where various categories of users can log on to get
at secure pages. I do this by checking usernames and passwords against a
list in a database and set session("loginadmin")=true or
session("loginctte")=true depending on what category is stored in my
database. On the secure pages I now want to put a log off button and am
interested to know what code I need.

Currently I have created a form and this calls a page (logouthandler.asp).
The code on this page is

<%
session("loginadmin")=false
session("loginctte")=false
response.redirect ("../index.asp")

%>

Just to make things simpler (in my opinion without seeing your other
code), I have typically used something like:

session("usertype") = "admin"

when logging on and then check the usertype session variable later
when trying to determine if a feature is available, etc

select case session("usertype")
case "admin":
case "ctte": ' huh?
case else: response.redirect "/index.asp"
end select

As already stated, all you need to do is abandon the session to "log
out" then.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top