RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TEndUserSessionAdapter Class

TEndUserSessionAdapter provides information about the current end user such as the user name, user ID, and whether the user is logged in.

Pascal
TEndUserSessionAdapter = class(TCustomEndUserSessionAdapter);
C++
class TEndUserSessionAdapter : public TCustomEndUserSessionAdapter;

Add TEndUserSessionAdapter to a WebSnap application where users must log in before accessing Web pages. TEndUserSessionAdapter handles login and logout actions on behalf of the end user. TEndUserSessionAdapter uses the TSessionsService component to store information about the current end user. The WebSnap application must contain a TSessionsService component (or equivalent) in order for the TEndUserSessionAdapter to work properly.  

TEndUserSessionAdapter supports two default Adapter fields: DisplayName and LoggedIn. These fields provide access to the user's name and login state. TEndUserSessionAdapter retrieves the values for these fields from a Web session, which is maintained by the TSessionsService component. 

TEndUserSessionAdapter supports two default actions: LoginForm and LogoutOut. These actions are used to display a login form and to log the user out. Use the LoginPage property to specify the name of the login page. The default implementation of the logout action terminates the session. 

The EndUser script variable is used by server-side script to display end user information and execute end user actions. The following JavaScript displays the name of the logged in end user, if any.

<% if (EndUser.LoggedIn) { %>
<h1>Welcome <%= EndUser.DisplayName %> </h1>
<% } %>

The following JavaScript displays a login or logout hyperlink.

<%   if (EndUser.Logout.Enabled) { %>
  <a href="<%=EndUser.Logout.AsHREF%>">Logout</a>
<%   } %>
<%   if (EndUser.LoginForm.Enabled) { %>
  <a href=<%=EndUser.LoginForm.AsHREF%>>Login</a>
<%   } %>

TEndUserSessionAdapter also determines access rights for a user. If the WebSnap application contains a TWebUserList or equivalent, TEndUserAdapter calls the TWebUserList component to check rights for a particular user ID. Implement the OnHasRights event to check rights in an event handler. 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!