How to log off a user

Vote:
 

Once a user has logged in to EPiServer Community, how do I logg this user off?

 

#20509
Jun 03, 2008 10:54
Vote:
 

Hi,

There are a couple of different methods available for authentication in .NET, where the most popular kind is FormsAuthentication. It enables use of regular textboxes on a web page to be used as the login form, and uses cookies to store authentication data. I will assume that you are using FormsAuthentication.

There are (at least) two options. The first involves using the LoginStatus class in System.Web.UI.WebControls: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.loginstatus(VS.85).aspx
The control detects the user's authentication state and toggles the state of a link to log in or log out of a web site.

Behind the scenes, the LoginStatus control calls FormsAuthentication.SignOut(), which removes the authentication data from the cookie mentioned above. See MSDN on this method here: http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.signout.aspx

Regards,

Kristoffer Sjöberg
EPiServer AB

#20513
Edited, Jun 03, 2008 15:15
Vote:
 

Hi,

Also worth mentioning is the OnlineStatus-module in EPiServer Community that keeps track of which users are actually logged in to the community. You can set a user to appear offline by calling:

StarCommunity.Modules.OnlineStatus.OnlineStatusModule.LogOffUser(IUser user);

Otherwise the user will automatically appear offline after 20 minutes of inactivity. 

Regards,

Mattias Nordberg 

#20518
Jun 03, 2008 16:51
Vote:
 

Hi,

The first option to use a webcontrol tp toggle log in and log out behavior is not exactly what I need, The user logs in on one webpage and loggs off on another.

 Using LogOffUser seems more like it. But, when I type in StarCommunity.Modules. in VS the only thing to choose next is Forum. Am I missing an assembly or how can I find LogOffUser?

regards

Madelene 

#20529
Jun 04, 2008 10:49
Vote:
 

Hi,

You should add the references you need to your project, they are located in the web application's "bin" directory after installation. For the OnlineStatus-module you will need to add StarCommunity.Modules.OnlineStatus.dll.

Regards,

Mattias 

#20560
Jun 04, 2008 16:56
Vote:
 

Hi,

I found LogOffUser by adding a reference to the dll you mentioned. Thank you.

To do the actual log off I use FormsAuthentication.SignOut();

regards

Madelene 

#20571
Jun 05, 2008 10:02
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.