[SOLVED] Clear all session from web

Answered
0
0

I am implementing the user logout function. However, I can not find the best way to clear all session froms application.

We have Session.Clear(), Session.RemoveAll() and Session.Abandon() to remove all sessions from Asp.Net web.

In the Wisej, How can I do that?

Thank you.

  • Jorge Bastos
    Found it! “autoReload”: true, in Default.json
  • You must to post comments
Best Answer
0
0

Session.Clear or Abandon or RemoveAll don’t clear all sessions. It only clears all values stored in the single current session.

In Wisej if you want to terminate a session or an application use Application.Exit(). If you stored something in the session object use Application.Session.Clear(). The Application.Session object is a dynamic object in Wisej but it also implements the IDictionary interface.

To close all open windows iterate the Application.OpenForms collection. However when you call Form.Close if your code handles FormClosing and cancels the form will not close. You can force it calling Close(CloseReason.ApplicationExit) but it’s an internal method, you’d have to call it using reflection. We can make it public if needed.

  • Truong Nguyen
    I just need to clear all session values. Can Application.Session.Clear() dymanic method help it?
  • You must to post comments
0
0

Hi,

Application.exit() does the job, but how can I do to to again to the login page after it?

Thanks in advanced,

  • Levie (ITG)
    Hi Jorge, you should use the method described by Luca below: iterate through Application.OpenForms and close them all. After closing all of them, Re-open the Login form (dim frm = new LoginForm(), frm.Show(),). You could also just not close the original login form but could hide it instead. So, you would iterate through Application.OpenForms closing each one, except if the form is the hidden login window (unhide /show it). Then go on to clear your session variables with Application.Session.Clear(). Does this make sense? -Levie
  • Jorge Bastos
    Thanks Levie, I’ve done it with the autoReload: True in default.json, works great, It’s also a way of doing it right?
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.