Solved

Session Still Working Despite Using Session.Abandon()

Posted on 2013-01-07
6
310 Views
Last Modified: 2013-01-12
Hello guys..

I am using Session.Abandon() to logout from a page called detail.asp and then redirecting to Login.asp. But from login.asp page when I use the same link of detail.asp in the address bar it takes me into the same detail.asp page instead of redirecting back again to login page.

logout.asp
----------------------
session.abandon
response.redirect "login.asp"
0
Comment
Question by:newbie27
[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
  • 3
  • 3
6 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 38750596
Try Session.Contents.Remove("sale") or for all sessions Session.Contents.RemoveAll().  I will typically do this session("myobject")="" first.
0
 
LVL 8

Author Comment

by:newbie27
ID: 38751182
No it didn't work.

From detail.asp page i am calling logut.asp page

logout.asp page cotains the following code

Session.Contents.RemoveAll()
session.abandon
response.redirect "login.asp"

Being in login.asp page, when i paste the detail.asp link in the address bar it takes me to again to details.asp which it should redirect back to login page
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 38751249
Can you post your sample script.

This works for me.
Page1.asp
<%
session("login")="xyz"
%>

Page2.asp
<%
Session.Contents.Remove("login")
session.Contents.RemoveAll()
%>

Are you sure the code is being called?
Try this
Session.Contents.Remove("login")
Session.Contents.RemoveAll()
session.abandon
response.write "Login removed."
response.end() 'should stop the page and verify your code is processed.
response.redirect "login.asp"
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 8

Author Comment

by:newbie27
ID: 38753592
Login.asp
-----------------------------------------------------------------
UserName = request.form("UserName")
Password = request.form("Password")

session("UserName") = UserName

After successful login it will redirect to detail.asp page

detail.asp
---------------
Dim sUsername
sUsername = Session("UserName")
If sUsername = "" Then
Response.Redirect("login.asp")
end if
below code will show details with logout option
<a href="logout.asp" style="float:right"><b>LogOut</b></a>

logout.asp
-----------------
<% in this page i also want to clear the cookies, for now just trying to kill the session
'dim Cookie
'For Each Cookie In Response.Cookies
'Response.Cookies(Cookie).Expires = Date() - 1
'Next
'DeleteSession
Session.Contents.Remove("UserName")
Session.Contents.RemoveAll()
session.abandon
response.write "Login removed."
response.end()
response.redirect "login.asp
'end if
%>

when i followed the steps and clicked on the logout link it shows the error of "The page cannot be displayed".

Please advise.
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 38753652
Login.asp
<%
'just to make sure default the session to nothing
   session("UserName") =""

'only set the user info if the form is submitted
if request.form("UserName")<>"" then
   UserName = request.form("UserName")
   Password = request.form("Password")
    session("UserName") = UserName
end if
%>

Open in new window

0
 
LVL 8

Author Closing Comment

by:newbie27
ID: 38769968
Thanks, worked like a charm.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Batch file or script with password 22 85
Collapse and expand table in Word 2010 2 91
Records from Access to Excel to specific cells 5 36
VB script to continue despite error 2 48
In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

735 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