473,395 Members | 1,583 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

clear session

Dear All,

I have an ASP.net page. When I am closing the webpage I need to clear the session variables.

I need to close the session variales at time of my browser is close directly,without using the logout link.

Is there any possiblity for clearing the session variable.

Thanks
Anitha
Sep 7 '09 #1
7 5484
maliksleo
115 100+
use the page unload event or try to use java script for that on window.close() function remove your all sessions.
Sep 8 '09 #2
ssnaik84
149 100+
try using AJAX with body onunload event
Sep 8 '09 #3
Frinavale
9,735 Expert Mod 8TB
You should use the onbeforeunload javascript event.

This event is fired just before the page is unloaded. After the onbeforeunload event (the unload event is fired) the page is unloaded JavaScript and Ajax are no longer available to you. Please look over the article I linked you to because this event is a bit special.

After you've read that check out this solution that outlines how to clear session using the onbeforeunload event and Ajax.

Happy coding!

-Frinny
Sep 8 '09 #4
Frinavale
9,735 Expert Mod 8TB
Hmm, I just read through the post I linked you to and I realized that there's probably an easier way to "register" your controls on the page.

When the page is loaded (javascript window.onload event or during the Ajax end request event) you could use JavaScript loop through all of the controls on the page and add events instead of doing this on the server.


:)

-Frinny
Sep 8 '09 #5
ssnaik84
149 100+
heyy.. that's great articles Frinny!! thanks a million.. :)
Sep 9 '09 #6
ssnaik84
149 100+
I would like you to take a look at http://www.irctc.co.in
It is an official website for ticket booking by indian railway.
it has huge database and millions of transactions held on daily basis.
they have same functionality implemented but in different way.
they are sending session id in URL and checking each time on page_load, i guess.
obviously, it is not developed in asp.net, but i m just trying to point out their implementation way.
-- swapnil
Sep 9 '09 #7
Frinavale
9,735 Expert Mod 8TB
They're using cookieless session.

ASP.NET has that option too...you can set it in the web.config file if you want to. It's not as secure as using a cookie because you can just copy the URL (which includes the session ID) and pass it on to some other person (who may, as a result of the session ID in the URL, be logged in as that user etc).

It's handy in some scenarios but not in others.

I'm glad you liked the link. I'm in the middle of converting it into an article because your question is quite commonly asked.
Sep 9 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Don Grover | last post by:
USing ASP, MSSql on W2k3 I am worried of accumulated old cart product selections from expired browser windows or other unforseen events. I am holding selected productID's & quantities & userID...
3
by: JezB | last post by:
I want to clear some specific Session variables when the user closes a page. On my page I have a "return to ..." button which navigates back to the parent page from which it was invoked - under the...
0
by: dummy_2600 | last post by:
I have an app I'm a trying to roll out to production in which Session.Clear() doesn't seem to be working for me. Basically we have multiple forms that make up a registration process. At the end...
5
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...
1
by: prefersgolfing | last post by:
I have set up several session variables and can read/write as expected. My problem is when I start another debug session the variables are retaining the values from the previous debug session. I've...
4
by: Alex D. | last post by:
Hi. I have a TreeView stored in a session variable...is ok...problem is when I use Nodes.Clear() then my session variable that holds the TreeView is also emptied! Is this behavior by design or...
1
by: ABC | last post by:
Will Session automatic clear memory when I unload web page?
2
by: ESmith | last post by:
How can I clear the current session cache of previously visited webpages? That is, say I start up my app (with browser component), point to www.cnn.com, click on several links, then I want to...
1
by: Nathan Sokalski | last post by:
Is there a difference between Session.Clear() and Session.RemoveAll()? The descriptions and documentation pages seem to say exactly the same thing, but I am assuming there must be some reason for...
0
by: Bati | last post by:
Hello, I am trying to clear all the sessions variables from ALL Web applications as the web site is made of several web applications. When I do use: Session.Clear() or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.