Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Terry Clancy 204 posts 944 karma points
    Dec 30, 2015 @ 08:53
    Terry Clancy
    0

    After Logging in Members fall off-line after two pages.

    Dear Umbraco folk,

    I am configuriing Membership for my new site Umbraco 7 MVC / UCommerce site and

    After Members Login using my Login web page, they show as Online for the immediate next page only, but then fall offline for subsequent pages :-(

    To summarize my code showing only relevant bits, this is how my Login page Logs a Member in:

        // Get the Umbraco MemberService
        var umbMemberService = AppHelpers.UmbServices().MemberService;
        // Get the Umbraco Member
        var umbracoMember = umbMemberService.GetByEmail(model.EmailAddress);
        // Create and instance of the MembershipHelper
        var membershipHelper = new MembershipHelper(UmbracoContext.Current);
        string thisUserName = umbracoMember.Username;
        if (membershipHelper.Login(thisUserName, model.Password))
        {
            // Do several actions for successful logon here including
            FormsAuthentication.SetAuthCookie(model.EmailAddress, true);
            // Note also that debugger shows FormsAuthentication.Timeout = {00:30:00}  or 30 minutes
        }
    

    The Login page returns a redirect along with the following cookies in the Responce header (using IE Debug tools):

        yourAuthCookie=02C642782F0F8433291759C78F3B879FBF061C359EE74ACC4B214C0F7E1FDBE26FCA0E37CF61F3581BF8C2A7EE04304F2CACD4B8F44C4233EF845DDB6EB8A524BFF06D3C10CF5249F71C5844B6DF4310F4DF28410678B500A29FAFDF08B3439523BA8F08A3EF25C8C4F9FC9990F31A42; 
    expires=Wed, 30-Dec-2015 08:56:26 GMT; path=/; HttpOnly
    
        yourAuthCookie=4C1A7CA68BF4920036A90A682AD302395EA57B5FDC2682D143F86B8B7E23A669366A0EFA5D382E19EA59A895B2184323DF680E062734ED62ECF96B5B27E3B63E310F50146BC455C574B50B48611CA05ACBCD68DCC282559F6C7FDF89BD6AEA82DCCE94DF03DA92993D20ADE1F90103BC5537FC985279577D957C01775003924C; 
    expires=Wed, 30-Dec-2015 08:56:32 GMT; path=/; HttpOnly
    

    I am not sure why there are TWO "yourAuthCookie"s ?? Anyway those time outs are 30 minutes in the future so that seems fine.

    When the browser requests the redirect page, I see that the Request Header includes the following

       Cookie: basketid=4453f3e8-0240-4e89-b1b2-af4ed62a362d; pricegroup=7; UMB_UPDCHK=1; 
    __RequestVerificationToken=EekALQkgIjZ6kgV08e7i27CMGDfPR3GtPZGgNZ8shzc5VwFnbS3rKJgBSpFPMfjRgCi6MRgYVpXS1wvRHZd3fImKuJKyHbSg-Kf-isYfW4M1; 
    yourAuthCookie=4C1A7CA68BF4920036A90A682AD302395EA57B5FDC2682D143F86B8B7E23A669366A0EFA5D382E19EA59A895B2184323DF680E062734ED62ECF96B5B27E3B63E310F50146BC455C574B50B48611CA05ACBCD68DCC282559F6C7FDF89BD6AEA82DCCE94DF03DA92993D20ADE1F90103BC5537FC985279577D957C01775003924C
    

    But I also see that the Responce Header with that page includes the following

    Set-Cookie: yourAuthCookie=; expires=Tue, 12-Oct-1999 07:00:00 GMT; path=/; HttpOnly
    

    WHICH IS IN THE PAST !!!! which probably explains why I am then logged out when I try and visit any subsequant pages.

    Any clues as to what may be causing this and/or how to fix would be greatly appreciated.

    Thanks very much

    Terry Clancy

    ClanceZ

  • Terry Clancy 204 posts 944 karma points
    Dec 30, 2015 @ 19:02
    Terry Clancy
    100

    Hi again,

    Never mind, I found the problem.

    I needed to remove the following line from my code shown above:

    FormsAuthentication.SetAuthCookie(model.EmailAddress, true);
    

    I assume that either Umbraco or ASP.Net (probably ASP.Net) is doing that for me and it is unnecessary to do it here.

    With that removed only one "yourAuthCookie" is set and everything seems to be working as expected.

    Thanks

    Terry Clancy

    ClanceZ

Please Sign in or register to post replies

Write your reply to:

Draft