Site structure
Version 5.x > Site structure > Creating session for mobile device View modes: 
User avatar
Member
Member
jacbar - 12/14/2011 9:29:54 AM
   
Creating session for mobile device
Hi,
I've got two mobile webpages, which repeat content from original webpage, but they are only for authenticated users. Is there any posibility to create seesion/authentication cookies sending username and password, without the need of manual login?

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 12/16/2011 7:17:21 AM
   
RE:Creating session for mobile device
Hi,

Maybe I don’t quite understand the point of having secured area and then creating authentication cookie for any user by API (of course, it is possible to create authentication cookie based on the user name of existing user in CMS_User table).

Based on what kind of information you would like to authenticate the user? Wouldn’t it make sense to disable need for authentication for those two pages?

You can find example on how to create authentication cookie for user based on his/her user name in ~\CMSWebParts\Membership\Registration\RegistrationForm.ascx.cs file (version 5.5R2):

FormsAuthentication.SetAuthCookie(ui.UserName, true);
CMSContext.SetCurrentUser(new CurrentUserInfo(ui, true));
UserInfoProvider.SetPreferredCultures(ui);


ui in this context is some existing UserInfo object.

Thanks,
Miro