473,608 Members | 2,689 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Session is not letting me remove keys

I have an application that is using Session state. On one page, I use the
Session.Add() method to create the Key/Value pair for the first time. I am
then sent to another page using Response.Redire ct(). On the page I am sent
to, I can view the Session's value using Session("mykey" ), but it will not
let me remove or modify it. I have tried Session("mykey" ),
Session.Remove( "mykey"), Session.Clear() , and Session.Abandon (). None of
these seemed to make any change to Session (I have tried checking whether
Session("mykey" ) has a value using both Session("mykey" )="" and
Session("mykey" ) Is Nothing). When I first go to the page that checks
whether Session("mykey" ) has a value before using Session.Add(), it does
recognize that is does not have a value. Also, when I tried calling
Session.Abandon () twice by clicking the Button that calls the method, it
seemed to work, but not if I call it twice one immediately after the other.
I have EnableSessionSt ate="True" in the @Page and <pages
enableSessionSt ate="true"in my Web.config file. Does anybody have any idea
why I might be having this problem? Thanks.

Nathan Sokalski
nj********@hotm ail.com
http://www.nathansokalski.com/

Aug 29 '07 #1
2 1486
Nathan Sokalski wrote:
I have an application that is using Session state. On one page, I use
the Session.Add() method to create the Key/Value pair for the first
time. I am then sent to another page using Response.Redire ct(). On the
page I am sent to, I can view the Session's value using
Session("mykey" ), but it will not let me remove or modify it. I have
tried Session("mykey" ), Session.Remove( "mykey"), Session.Clear() , and
Session.Abandon (). None of these seemed to make any change to Session (I
have tried checking whether Session("mykey" ) has a value using both
Session("mykey" )="" and Session("mykey" ) Is Nothing). When I first go to
the page that checks whether Session("mykey" ) has a value before using
Session.Add(), it does recognize that is does not have a value. Also,
when I tried calling Session.Abandon () twice by clicking the Button that
calls the method, it seemed to work, but not if I call it twice one
immediately after the other. I have EnableSessionSt ate="True" in the
@Page and <pages enableSessionSt ate="true"in my Web.config file. Does
anybody have any idea why I might be having this problem? Thanks.
The Remove method and the Clear method should absolutely remove the
values from the session variables collection. You must have made some
mistake when using them.

The Abandon method doesn't remove anything from the session object, it
only registers that the session will be abandoned when the request has
been completed. The current Session object is still available during the
execution of the current page. When the next page is requested, a new
Session object will be created.

--
Göran Andersson
_____
http://www.guffa.com
Aug 29 '07 #2

//
The Abandon method doesn't remove anything from the session object, it
only registers that the session will be abandoned when the request has
been completed. The current Session object is still available during the
execution of the current page. When the next page is requested, a new
Session object will be created.
//

Ditto on that. The Abandon will "trick you" until you figure out that it
happens after the execution of the current page.

One of the reasons I wrote this:
http://sholliday.space s.live.com/Blog/cns!A68482B9628 A842A!151.entry

was because I had a better Remove and Clear methods to call.

"Göran Andersson" <gu***@guffa.co mwrote in message
news:eN******** ******@TK2MSFTN GP04.phx.gbl...
Nathan Sokalski wrote:
>I have an application that is using Session state. On one page, I use the
Session.Add( ) method to create the Key/Value pair for the first time. I
am then sent to another page using Response.Redire ct(). On the page I am
sent to, I can view the Session's value using Session("mykey" ), but it
will not let me remove or modify it. I have tried Session("mykey" ),
Session.Remove ("mykey"), Session.Clear() , and Session.Abandon (). None of
these seemed to make any change to Session (I have tried checking whether
Session("mykey ") has a value using both Session("mykey" )="" and
Session("mykey ") Is Nothing). When I first go to the page that checks
whether Session("mykey" ) has a value before using Session.Add(), it does
recognize that is does not have a value. Also, when I tried calling
Session.Abando n() twice by clicking the Button that calls the method, it
seemed to work, but not if I call it twice one immediately after the
other. I have EnableSessionSt ate="True" in the @Page and <pages
enableSessionS tate="true"in my Web.config file. Does anybody have any
idea why I might be having this problem? Thanks.

The Remove method and the Clear method should absolutely remove the values
from the session variables collection. You must have made some mistake
when using them.

The Abandon method doesn't remove anything from the session object, it
only registers that the session will be abandoned when the request has
been completed. The current Session object is still available during the
execution of the current page. When the next page is requested, a new
Session object will be created.

--
Göran Andersson
_____
http://www.guffa.com

Aug 29 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
7105
by: mrbog | last post by:
Tell me if my assertion is wrong here: The only way to prevent session hijacking is to NEVER store authentication information (such as name/password) in the session. Well, to never authenticate a user from information you got from the session. Each secure app on a site must challenge the user for name and password, each and every time the user accesses it (not just once and then store it in the session). If a secure app is multi-page,...
2
24620
by: MFRASER | last post by:
How do I go about looping through a hash table and removing items. I know how do this in a collectionbase, but can't iterate through the hash table with out getting an error. Here is my sample code for a collection base for(int i = this.Values.Count; i > 0 ; i--) { //Set local object
4
3477
by: Fredrik Rodin | last post by:
Hi! I want to basicaööy run a Session.Abandon() on logout but keep one session. In order to do this I'm iterating through my session collection by runing the follwoing code: Dim iSessionCount As Integer = Session.Count - 1 For i As Integer = 0 To iSessionCount
5
22150
by: tshad | last post by:
When I log of I do: HttpContext.Current.Session.Clear() FormsAuthentication.SignOut() The problem is that it clears the variables that I set up in my Session_Start function in my Global.asax file. One of the variables I set up is:
4
4451
by: Amy | last post by:
I'm having a problem with clearing my session variables. I'm using session variables to pass data from a web form to a pdf generator. The problem comes in when a user goes back to the original page and takes data out of the field - the session variable is persisting. i tried the following, and it didn't work - I'm not sure where to go from here. Any advice would be appreciated. The string being passed is both the variable name and the...
6
7172
by: tshad | last post by:
Is there a reason to use session.remove over session.contents.remove? Don't they both remove the key and data from the contents collection? I assume that session(x) = nothing does essentially the same thing but is actually deleted later by the GC. Thanks, Tom
4
3735
by: Nick Gilbert | last post by:
Hi, Is it possible to access the Session of an arbitary user from an aspx page? On an e-commerce site, I am notified of payment success via a callback from the payment server to an ASPX page on my system. I would like to be able to access the session of the user that submitted the order, and clear their basket. I don't really want to store their session in the database just to facilitate this.
2
2456
by: fReDiNi | last post by:
Hi, I have an strange problem with session variables. I have a site hosted in a local server. I have physic access to this server and its configuration.(apache, php,files...). I have external access to the web site by typing the public ip address of the local server. I have a domain too, and this domain is redirected to the static public ip of the local server so when I type (out of the local server net) the
8
3363
by: dbarker1 | last post by:
This may be a can of worms but I wanted to throw it out here. I am gathering pros and cons for using querystring vs session variables for passing row keys in a ASP.net application. I want to be as thorough as possible so why not throw out this situation to the development community. Thoughts and opinions are appreciated.
0
8050
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7987
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8464
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8130
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6000
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3954
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2464
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1574
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1318
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.