Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 18th, 2004, 12:57 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default Session.Abandon problem

Hi All,

In my web application I have a user login. When the user loggs in I enter some information in a database table with SessionID as the Primary Key. After the user loggs in he can log out using a log out button in which I have written the following code

     Session.Abandon();

Now the user can again log in by clicking on the login button.

However, I find that both the old session id and the new session ID's are the same. So I get a primary key violation.

Can anybody tell me why I get the same session ID even after I do "Session.Abandon();" ?

Or is there any better way of doing the same??

Regards
Ganesh

__________________
Regards
Ganesh
http://ganeshprof.blogspot.com
Find your solution here...
 
Old September 19th, 2004, 02:59 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Session.Abandon basically resets the session. It clears out all session data, but it doesn't drop the session completely. Can you add code next to the call to Session.Abandon that clears the row(s) from the database with the session key? This would make sense cause your old session data isn't of much use any more. Unless you are storing for some historical reason.
 
Old September 19th, 2004, 11:25 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

Can you please explain more. How can we clear the session row srom the database? I am using iis session.

Thanks in advance
Ganesh

 
Old September 21st, 2004, 06:55 AM
Registered User
 
Join Date: Sep 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try This

Session.Contents.RemoveAll();

 
Old September 22nd, 2004, 12:18 AM
Friend of Wrox
 
Join Date: Sep 2004
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
Default

session id will remain the same if u will use the same ie window... on logout close the current window and open a new window showing ur loging page...


 
Old September 23rd, 2004, 01:37 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

Thanks Darsin for your suggestion.

But what to do in case the session is automatically timed out??

Ganesh

 
Old September 27th, 2004, 11:55 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Quote:
quote:Originally posted by DARSIN
 session id will remain the same if u will use the same ie window... on logout close the current window and open a new window showing ur loging page...

This will not work in some cases. With I.E. any window that is opened by script is in the same session, so you can't drop the session.
 
Old September 27th, 2004, 11:56 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Quote:
quote:Originally posted by r_ganesh76
 Can you please explain more. How can we clear the session row srom the database? I am using iis session.


How about:

"DELETE FROM sessiontable WHERE sessionid='......'"
 
Old September 27th, 2004, 11:58 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Of course, I just realized something. Based on what I beleive to be a "session", you shouldn't remove it because of a logout. Perhaps you need to add something to the data you store that tells you whether the current user is actually logged in or not. This is what I have done. The session data is good for the life of a user's session, whether or not they are logged in.
 
Old September 27th, 2004, 11:08 PM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

Thanx planoie for your suggestions.

Can you tell me where I can find this sessiontable? I mean in which database??

Regards
Ganesh





Similar Threads
Thread Thread Starter Forum Replies Last Post
session.abandon() sarah lee ASP.NET 1.0 and 1.1 Basics 4 December 11th, 2006 06:10 PM
Logout and Session.Abandon() fskilnik Classic ASP Basics 6 October 25th, 2005 05:17 PM
session.abandon!! cici Classic ASP Professional 1 April 16th, 2004 12:48 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.