What happens to the current session after calling session.showurl

When a user first his the webapp they land on a login page. After logging in I have a log out button and I found that if I call Session.ShowURL("") the web app is reloaded just as if they hit the browsers reload page button. This works just like I want to without having to do any session cleanup. I got tho wondering , however, what does happen to the current session after the call to ShowURL?

Which begs the question… is there anything wrong with using ShowURL("") to log out of a web app and return to the initial landing page? After reading comments on the forum on topics similar to this one, I thought this was just too simple to be any good. Nothing in the docs says that passing an empty string to ShowURL reloads the page. I also found that I can call ShowURL("?test=success") which reloads the page with a url parameter properly attached. Then if I call ShowURL("") again it includes the parameter again. I can, however, call ShowURL("/") and the parameter is removed.

Is this documented anywhere?



Don’t showURL the app. Use HandleURL to show a static page instead.

Is there a reason to not showURL the app?

First of all, ShowUrl is fine for what you are doing. It’s for redirecting the user away from the current session.

As for your first question, the reason it behaves this way with an empty string is because of the underlying mechanism. Supplying an empty string is akin to giving an empty relative path in a shell command. It just goes to the same location.

In terms of what happens to the session, technically you’ve redirected away from the current session (we’ll call it old) and created a new one. The old one will exist up to 3 minutes, just in case the user presses the back button to get it back.

That will simply start a new session.

@Greg O’Lone Thanks. Good stuff. You answered my question.

@Michel Bujardet “that will simply start a new session”

I think that’s just what I want to do and I am not sure how to use the handleURL event instead. How is using handleURL different or better than using showURL.

If all you want is show again the log in page, that is fine.

HandleURL would allow you to quit the app for good.

It is rather simple. Look at http://documentation.xojo.com/index.php/WebApplication.HandleURL

So to quit for good, you would point to a virtual directory above your app, for instance /bybye/, and in handleURL, instead of Hello World, put whatever message you like.

@Michel Bujardet “If all you want is show again the log in page, that is fine.”

Yes I think that is what I was looking for.

So the advantage is that the “old” session does not hang around but the app quits for good.

I did try to get my head around how to use HandleURL in a log out button. The only way I coudl figure was to call ShowURL("/goodbye"). Is there another way to do it?

The other thing that made me shy away from this approach was the extra effort to create an html response that looked nice and provided a link back to my app log in page. ShowURL("") seems to do that quite nicely and easily.

FWIW, I am also using ShowURL now for my app timeout. Before calling ShowURL("") I am dropping a cookie that is named timeout. When the app launches it checks to see if the timeout cookie exists and if it does clears it then throws a MsgBox saying “Your session has timed out”. When the MsgBox is closed, the log in page opens ready for the user to log back in again.