Does i need to apply Sessions in ASP.NET for log in/log out if im using SimpleMembership in MVC?

266 views Asked by At

I am new to web development so, do i need to implement sessions while i am using SimpleMembership as i was having problem with back button after logs out. It goes to the previous page instead of login. So I added code below in global.ascx. It works perfect now!!

Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetExpires(DateTime.UtcNow.AddHours(-1));
Response.Cache.SetNoStore();

So my query is, can i run my application without sessions in which there is Authentication of users i.e. there are user accounts and login and logout functionality is there.

1

There are 1 answers

2
Saket Kumar On

You can login and logout by using default SimpleMembership functions:

For Login:

bool success = WebSecurity.Login(form["username"], form["password"], false);

For Logout:

 WebSecurity.Logout();

For details refer MSDN link here