1379
Views
7
Comments
Clear session variable when the application is closed
Question

Hi,

I would like to clear the session variables when the application is closed. May i know where and how can i clear it?

2018-11-06 14-26-44
Suraj Borade

Hi Jace,

How are you closing the application? From browser without logging out or with keyboard keys?

UserImage.jpg
Jace Jace

Hi,

My application does not require login. So the application will be closed when the user close the browser.

2017-07-15 18-41-36
Sachin Mahawar

Hi Jace,

You can use below JS to clear session variable on Close of your application.

$(document).ready(function()
{
    $(window).bind("beforeunload", function() { 
            var elemid = $('.autobutton').attr('id');
            var elem = document.getElementById(elemid);             
            if (typeof elem.onclick == 'function')
            {                 
                elem.onclick.apply(elem);
            }
         
        //return confirm("Do you really want to close?"); 
    });
});

I am also here with attaching sample oml for your reference.

Sachin

FakeNotifyCall.oml
UserImage.jpg
Jace Jace

Sachin Mahawar wrote:

Hi Jace,

You can use below JS to clear session variable on Close of your application.

$(document).ready(function()
{
    $(window).bind("beforeunload", function() { 
            var elemid = $('.autobutton').attr('id');
            var elem = document.getElementById(elemid);             
            if (typeof elem.onclick == 'function')
            {                 
                elem.onclick.apply(elem);
            }
         
        //return confirm("Do you really want to close?"); 
    });
});

I am also here with attaching sample oml for your reference.

Sachin

Hello,

Thanks for the oml. But when and where should i call the screen action. 

I want to clear all the session variables whenever user reopen the application.


2022-11-15 07-57-26
sumant kumar

No, it's not working. 

2017-08-28 11-56-10
Debasis Sahoo

Hi Jace,

you can follow a method to call server side logout page on unloading of your document area using jquery.

  $.post("logout.aspx?action=logout",{},function(data){
    location.href="logout.aspx";
});

you can call this inside your document unload function defined at page level.


2022-11-15 07-57-26
sumant kumar

The session storage will automatically clear when you close the application or browser. But local storage will remain there.


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.