Wrox Programmer Forums
|
ASP.NET 1.1 As of 10/6/2005, this forum is locked as part of the reorganization described here: http://p2p.wrox.com/topic.asp?TOPIC_ID=35394. No posts have been deleted. Open ongoing discussions from the last week have been moved to either ASP.NET 1.0 and 1.1 Beginners http://p2p.wrox.com/asp-net-1-0-1-1-basics-60/ or ASP.NET 1.0 and 1.1 Professional. http://p2p.wrox.com/forum.asp?FORUM_ID=50. See my sticky post inside for more.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.1 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 January 22nd, 2005, 02:13 AM
Authorized User
 
Join Date: Sep 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default session abandon

Hi friends,

In a page i have two buttons and two labels

In the 1st button click i wrote this code....

{
Label1.Text = Label1.Text + "SessionID : " + Me.Session.SessionID + "<br>"
Label1.Text = Label1.Text + "Before ABN " + Me.Session.Item("hello") + "<br>"
Me.Session.Abandon()
Label1.Text = Label1.Text + "After ABN " + Me.Session.Item("hello")

}

when i clich the button the result is

SessionID : w4w2ks55on4gyt450ygmc3jl
Before ABN world
After ABN world

In the second button click....this code...

{
Label2.Text = Label2.Text + "SessionID : " + Me.Session.SessionID + "<br>"
Label2.Text = Label2.Text + Me.Session.Item("hello")
}

when i post back with the second button click(after the first button click only)the result is ..

SessionID : w4w2ks55on4gyt450ygmc3jl
world

In the first button click i called the Session.Abandon method...
But in the post back session is still valid ....

Why it is so ????

When I redirect to a new page it is working fine.....

Can any one help me........??????


cheers,
jais

 
Old January 22nd, 2005, 06:30 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

When you call Session.Abandon, the session is queued for deletion, but the actual destruction of the session variables doesn't take place until the entire page has finished loading. So, when you call Abandon, you can still use the variables in the current page.

To overcome this, either reset the value of the variables:

Session("MyVariable") = ""
Session.Abandon()

Or use Response.Redirect to send the user to a new page, where the session will no longer be available.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old January 22nd, 2005, 11:57 AM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 307
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Vadivel Send a message via Yahoo to Vadivel
Default

Use,
Session.Abandon()
Session.RemoveAll() //this would remove all elements from the session hash
and then redirect to the desired page (Response.redirect or Server.Transfer)

Best Regards
Vadivel

MVP ASP/ASP.NET
http://vadivel.thinkingms.com
 
Old January 24th, 2005, 01:51 AM
Authorized User
 
Join Date: Sep 2004
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Friends,
Thank You for the help....Now I understand the real cause.....

Happy Programming.....

Cheers,

Jais






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 problem r_ganesh76 General .NET 13 October 4th, 2004 11:20 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.