简体   繁体   中英

Implementing client-side ajax login, is it safe to logout using ajax or do I need to refresh?

I'm building a client-side ajax login for Asp.Net MVC by doing jquery posts to the controller to log in the user.

What I'm wondering is when the user goes to log out, should the page refresh? (for security reasons)

This tutorial here says:

There will always be a page refresh on logout. This is necessary to ensure that any user-specific information is cleared from the page.

And I figured since it's tutorial on doing client-side ajax login's that there must be a reason why they did it that way. If I do an ajax logout, is it safe to just switch everything to an anonymous view without reloading the page?

You don't need to refresh, Ajax is a simple HTTP request, so if the request properly logs you out on the server, you just need to make sure there's no relevant data left on the client, for example in a JavaScript object or in a cookie.

In any case you can still clean everything up without a page refresh.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM