Websession.Timeout does not appear to work

Hello all,

In the open event of Session, I have tried code:

Self.Timeout = 54000 // 15 minutes

This caused it to end the session in about 3 minutes. So I tried setting it to zero so it would never end. But it still does.
What am I doing wrong? My customers do not want to log back in every few minutes so I need to get this cured.

Thanks,
Tim

https://documentation.xojo.com/api/web/websession.html#websession-timeout says the value is in seconds, so your code above using 54000 seconds would actually be 15 hours, not 15 minutes. If the documentation is wrong, and it’s actually milliseconds, then you’d be setting it to 54 seconds (which is much shorter than 3 minutes). Puzzling.

[quote=473700:@Tim Seyfarth]Hello all,

In the open event of Session, I have tried code:

Self.Timeout = 54000 // 15 minutes

This caused it to end the session in about 3 minutes. So I tried setting it to zero so it would never end. But it still does.
What am I doing wrong? My customers do not want to log back in every few minutes so I need to get this cured.

Thanks,
Tim[/quote]

Self.Timeout doesn’t end sessions, it only fires the Session.TimeOut event.

See:
http://documentation.xojo.com/api/web/webapplication.html#webapplication-sessiontimeout
App.SessionTimeout ends the session after the given number of seconds of no activity.

And:

http://documentation.xojo.com/api/web/websession.html#websession-timeout

To be clearer:

App.SessionTimeout is the number of seconds a session will stay around after the browser stops communicating with the app. Like when a user closes their browser or navigates to another website.

Session.Timeout is the number of seconds that the user can stay idle (no keyboard, mouse or touch input) before the Session.TimedOut event fires. Banking websites use this to show a dialog when it appears someone has walked away and left their account logged in.

Session. Timeout is what I was using. In the Session.open event.
I also tried using a zero so it would never logout. Neither works tho.

Self.Timeout =0 

Should this code be placed instead in the main form open event as Session.Timeout = 0?

Tim

[quote=473769:@Tim Seyfarth]Session. Timeout is what I was using. In the Session.open event.
I also tried using a zero so it would never logout. Neither works tho.

Self.Timeout =0 

Should this code be placed instead in the main form open event as Session.Timeout = 0?

Tim[/quote]
But Session.Timeout doesn’t do that. Read what I posted above again.

Hi Greg,

I am using session.timeout (not App.sessiontimeout). The docs say that when using this in the Session object itself, to use Self.Timeout

And, to be clear, I want it to NOT timeout when no mouse or keyboard action by the user. Most of the time they just watch the screen, not user input required.
Tim

You probably are loosing the connection somehow.
Maybe xojo adds a cookie or some other way to keep the sessionid in the browser.

You could try to set

App.SessionTimeout = (24*60*60)

Hi Derk,

That is not the one I am interested in.

Session.Timeout is -

[quote=473789:@Tim Seyfarth]Hi Greg,

I am using session.timeout (not App.sessiontimeout). The docs say that when using this in the Session object itself, to use Self.Timeout

And, to be clear, I want it to NOT timeout when no mouse or keyboard action by the user. Most of the time they just watch the screen, not user input required.
Tim[/quote]
Right. In that case you don’t need to deal with Session.Timeout at all. Think of it as a timer on the browser that gets reset whenever the user moves the mouse or types a key. When the timer runs out, the only thing that happens is the TimedOut event fires on that users session. Nothing more. If you don’t do anything with the TimedOut event, setting or not setting Session.Timeout doesn’t matter one bit.

Now… you could try setting App.SessionTimeout to a number larger than 180, but be aware that when users legitimately leave your app, the session will also hang around for that period of time before freeing any resources associated with them.

The way this is supposed to work is that sessions stay alive as long as the browser is communicating with the app and that should be going on in the background all the time.

[quote=473793:@Tim Seyfarth]Hi Derk,

That is not the one I am interested in.

Session.Timeout is -[/quote]
You’re reading that wrong.

App.SessionTimeout is not the same thing as Session.Timeout.

If your users are getting booted from your system, we should be trying to figure out why that is because by default that’s not how web apps work.

Technically, if you made a completely blank app, a user should be able to access that app, walk away from their computer, and the session should stay open without you having to write any code to make that happen.

So if there is nothing in the Session.Timedout event, then it should stay on screen. Correct? Right now when that event fires, I have code in there asking the user if they want to stay or leave. I was trying to extend the time between them being asked that. I changed the value, which was incorrect and way to big, to 3600. So far that is working.

Further I understand the app.sessiontimeout <> session.timeout - I have no interest in chaning App.sessiontimeout since as you say, the session remains much longer. I would rather have the framework defaults manage that stuff…

Thanks for all of the feedback too!
Tim