Session Variables getting clear before logout

Session Variables getting clear before logout

  

Hi Team,


I am facing an issue where I am using a session variable to fetch some data using SQL, but when I leave my page idle for 20mins {standard idle timeout in .NET} and refreshes it after that I see blank data in the page. 


I debugged this scenario and noticed that the session variables gets cleared. Ideally it should get cleared only when user logs out. If it is getting cleared out then I should be redirected to login screen, which is not happening now.


Attached screenshot with blank region values.

Summary:

 1. If session variables are cleared out by keeping page idle, then I should be redirected to Login page. --- Not happening

2. session variables should retain their values unless user logs out ----  Not happening


Please let me know how to fix this.


Thanks

Atul

Jitendra Raghuvanshi wrote:

Hi Atul,

below link will help you.

https://www.outsystems.com/forums/discussion/34866/how-to-change-the-session-timeout-in-factory-configuration/

Thanks

Jitendra

Hi Jitendra,


I have already gone through this link, it does not make help to me.


I wanted to know why Session variables are getting cleared before logout.


Anyways thanks for you reply.


Thanks

Atul

Solution

Hello Atul,

When the session times out (20 min idle), the session variables are reset. Unless the user (or the application, automatically) is using the persistent login, the user will be logged out.

If you refresh the page and you're not being redirect to login, it must br because the page has the anonymous role checked, so anyone, even if not logged, can see the page.

As best practice, don't use session variables to store complex data. It will degrade (potentially) the application performance.

Hope this helps.

Cheers

Solution

Eduardo Jauch wrote:

Hello Atul,

When the session times out (20 min idle), the session variables are reset. Unless the user (or the application, automatically) is using the persistent login, the user will be logged out.

If you refresh the page and you're not being redirect to login, it must br because the page has the anonymous role checked, so anyone, even if not logged, can see the page.

As best practice, don't use session variables to store complex data. It will degrade (potentially) the application performance.

Hope this helps.

Cheers

Hi Eduardo,


1. I am not using Persistent login.

2. Page does not has the anonymous role checked.

3. I am not using session variables to store complex data. It just an identifier for language table. but when LanguageId is reset to null I do not get any translated text corresponding to that..


Thanks

Atul


Well

Refreshing the page will usually make the browser fetch the page from cache.

If the session timed out, you can try to navigate to another page not anonymous, or even load the same page again (not refreshing), and you will be redirected to the login page if your page is not anonymous.

But the session variables will be gone, as they are reset on session timeout.

Cheers

As a solution for the info, you can use a cookie to store the information.

Cheers

Eduardo Jauch wrote:

As a solution for the info, you can use a cookie to store the information.

Cheers

Thanks Eduardo, I will try this and post the results further.


Regards,

Atul


Hi Eduardo,


For my Information, Is there a time lag between session variables getting cleared and logout.


Thanks

Atul 

Afaik,

Session variables will be cleared on the first request after the timeout, as this will kill the old session and start a new one. At least.

Cheers

Eduardo Jauch wrote:

Afaik,

Session variables will be cleared on the first request after the timeout, as this will kill the old session and start a new one. At least.

Cheers

Is there a possibility of new session getting created without login. 


Thanks

Atul

If persistent login is not used, the new session will be an anonymous session (no user logged in)

Hello Eduardo,


I tried the suggestion you provided above and below are the results.


1. When I load the same page again (not refreshing) after keeping it idle for 20mins I got blank entries as attached in screenshot.

2. I again load the same page again (not refreshing) and this time I got the correct results, and this time the session variable has the non null value.


Can you suggest why this is happening.


Thanks

Atul

Hello atul. No image is showing.

Without understanding your logic, I can't explain. 

But I can say that if you are not being kicked to the login screen after session times out, you are using persistent login, or your page has the anonymous role marked.

Regarding the session variable, when the session times out, it will be reset to default value. After that, the new value will appear depending on which moment you set it in the session variable, that I do not know when it is, than I can't explain why you have this behaviour in your app.

Cheers

Hello Eduardo,


I actually drill down to the root cause of this issue and found the problem.

I was using "Remember Me" option in my login page and when the session ends the session variables were getting cleared but user was not logged out.


Thanks

Atul

As I had told you in the first comment ;)

Glad you solved the issue.

Cheers.

Eduardo Jauch wrote:

As I had told you in the first comment ;)

Glad you solved the issue.

Cheers.

Yes :)

Thank you very much to point me in correct direction.


I miss read your "persistent login" comments as persistent property of login action, which I have already marked as False.

Now I realised persistent login can be done using "Remember Me" property of User_login action as well.


Thanks again

Atul

You're welcome :)