Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 5th, 2003, 08:30 AM
Authorized User
 
Join Date: Aug 2003
Location: , , India.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to spraveens
Default Implementing "Logout"

Hi friends

             How do I implement "Logout " in ASP ?please help with code.

Praveen.

Reply With Quote
  #2 (permalink)  
Old November 5th, 2003, 08:37 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Well, it all depends on how you implemented Login.... ;)

If you are using Sessions to keep track of logged in users, a page called logout.asp with the following code would work:
Code:
<%
  Session.Abandon()
  Response.Redirect("/default.asp")
%>
This destroys the current Session object for the user and then redirects him / her to the homepage. You can provide a link to the logout.asp page from anywhere within your site.

If that doesn't help, describe your login mechanism in more detail.

Cheers,

Imar



---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #3 (permalink)  
Old November 5th, 2003, 11:35 PM
Authorized User
 
Join Date: Aug 2003
Location: , , India.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to spraveens
Default

Hi
 I have not implemented any session ,basically the login verifies the username/password from the database and redirects the user to the page.Now how do I implement Logout?

Thank you

Praveen

Reply With Quote
  #4 (permalink)  
Old November 6th, 2003, 04:05 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Well, it still depends on how you implemented the login... ;)

Checking the username and password against a database is only the first part. How do you save the state of the logged in user? That is, where do you keep something like a UserLoggedIn flag? In a cookie? Somewhere else? Do you check the username and password on every page?

If you don't store this state anywhere, logout is automatic. Because the Web is stateless, it will forget about the user after a page has been requested. This means that the user will have to log in again when they request another protected page, unless your site "remembers" somewhere that they have logged in already.

Does this make sense?

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #5 (permalink)  
Old November 6th, 2003, 04:43 AM
Authorized User
 
Join Date: Aug 2003
Location: , , India.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to spraveens
Default

Hi
   The login does not have any mechanism to store the details of the user.it taked the username/password from the user and then opens the database and then if correct than redirects the user to the home page else gives a password error message.now I want to implement a logout which would clear the cache (or page expires) and force the user to re login after pressing the Logout.pls give code

Thankz
praveen

Reply With Quote
  #6 (permalink)  
Old November 6th, 2003, 04:55 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Right, so you're not really after a "logout" feature, but you need to expire the page, right?

If you don't store login information, the user will not be really logged in. They have to supply a username and password to view the page, and that's it. If you need to expire the page so your users have to provide their username and password again, add the following code to the top of your page:
Code:
<%Response.ExpiresAbsolute = #1/1/1980#
Response.AddHeader "pragma", "no-cache"
Response.AddHeader "cache-control", "private, no-cache, must-revalidate"
%>
This makes sure that the page is not cached, and has to be requested again from the server. This will force your users to fill in their username and password again.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #7 (permalink)  
Old November 6th, 2003, 06:04 AM
Authorized User
 
Join Date: Aug 2003
Location: , , India.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to spraveens
Default

Hi
Thanks , Is it possible that only when I press the logout button all the cache is then cleared?so the user has to relogin only if he had pressed the "logout" button
praveen
Reply With Quote
  #8 (permalink)  
Old November 6th, 2003, 06:18 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

No. A page either expires (using the code I showed you) or does not expire.

You'll need to create a login mechanism that keeps track of the logged in user. You can use Sessions or Cookies for that. When the user logs out by pressing the button, you need to clear the Session variable. When the user tries to view the page again, this Session variable doesn't exist anymore, so your users need to log in again.

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
  #9 (permalink)  
Old November 6th, 2003, 06:26 AM
Authorized User
 
Join Date: Aug 2003
Location: , , India.
Posts: 78
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to spraveens
Default

Hi

thankz, Now how do i implement login/logout using sessions .plz help

praveen

Reply With Quote
  #10 (permalink)  
Old November 6th, 2003, 06:47 AM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Try this:

http://www.google.com/search?hl=en&i...n+sessions+asp

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
logout TIME and logout DATE crmpicco Classic ASP Databases 2 January 20th, 2005 12:01 AM
logout TIME and logout DATE crmpicco Classic ASP Basics 0 January 19th, 2005 07:57 AM
implementing logout spraveens Classic ASP Basics 4 November 6th, 2003 12:15 PM



All times are GMT -4. The time now is 06:29 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.