Using this to inherit/override the "default.aspx" / "umbraco.UmbracoDefault" page/class:
protected void Page_Init(object sender, EventArgs e)
{
if (!umbraco.library.IsLoggedOn())
{
// check if UserAgent contains a specific string
if (Request.UserAgent.Contains("***hidden***")
{
// Auto Login
var m = Member.GetMemberFromEmail("[email protected]");
Member.AddMemberToCache(m, true, TimeSpan.FromHours(1));
Response.Redirect(Request.RawUrl, true);
}
}
}
But, this no longer seems to work in Umbraco v4.7 (after an upgrade).
Thinking that it's most likely a cookie related issue - either with Umbraco or the MembershipProvider?
Any ideas, suggestions? I'd really appreciated it - starting to pull my hair out with this! :-$
I'm pretty sure that Umbraco 4.5.x and up uses the .net built-in membership stuff per default. This means, that you should try and use the native membership functions, I at least, have had great success with it so far.
I havent testet this exact code, but you should be able to do something like this in your auto login part:
var member = Membership.GetUserNameByEmail(email); var ticket = new FormsAuthenticationTicket(string name, bool isPersistent, int timeout); var encryptedTicket = FormsAuthentication.Encrypt(ticket); var authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket) { Expires = ticket.Expiration }; Response.Cookies.Add(authCookie); Response.Redirect(Request.RawUrl, true);
Auto-login member (front-end)
With Umbraco 4.7 is it possible to auto login a member - to access a protected area?
My main issue is that I previous had a working solution with Umbraco 4.0.x - using a code snippet from this forum post: Auto-login as a member for Google Mini Search
Using this to inherit/override the "default.aspx" / "umbraco.UmbracoDefault" page/class:
But, this no longer seems to work in Umbraco v4.7 (after an upgrade).
Thinking that it's most likely a cookie related issue - either with Umbraco or the MembershipProvider?
Any ideas, suggestions? I'd really appreciated it - starting to pull my hair out with this! :-$
Thanks, Lee.
Hey Lee
I'm pretty sure that Umbraco 4.5.x and up uses the .net built-in membership stuff per default.
This means, that you should try and use the native membership functions, I at least, have had great success with it so far.
I havent testet this exact code, but you should be able to do something like this in your auto login part:
Hope this can help you :)
/Mads
Thanks Mads!
Seems it was a different issue... my Web.config was missing the "cookieless=UseCookies" attribute for "system.web/authentication/forms"
After that, my original code works fine!
Cheers, Lee.
I'm setting the AuthCookie manually - just in case - thanks for the tip!
is working on a reply...