Important Notice from AspDotNetStorefront
It is with dismay that we report that we have been forced, through the action of hackers, to shut off write-access to this forum. We are keen to leave the wealth of material available to you for research. We have opened a new forum from which our community of users can seek help, support and advice from us and from each other. To post a new question to our community, please visit: http://forums.vortx.com
Results 1 to 2 of 2

Thread: getting thisCustomer info problem when programmatically logging in a user

  1. #1
    bdamore is offline Member
    Join Date
    Jun 2011
    Posts
    52

    Default getting thisCustomer info problem when programmatically logging in a user

    Hello,
    I have written some mods to DNSF to handle some interesting functionality.
    -I have to capture QS vars coming in from affiliate banners out there (affiliateID, ItemID-which crosses over to a productID in DNSF.)
    -Then, let the customer create an account (suppressing the billing/shipping info)
    -After account creation, post some of the data to an outside payment processor/affiliate system(data includes info forDNSF to handle a return completed purchase from this external source, eg: DNSFCustomerGUID gets passed)
    -The payment processor then posts a completed order to DNSF's orderconfirmation.aspx page (that I modified to handle the return...)

    I've learned (so I think) that when logging a user in, one must use the CustomerGUID as the cookie name. this might be the problem... Following signin.aspx lead I see that I use the CustomerGUID:
    Code:
    string cookieUserName = CustomerGUID.ToString();
                            bool createPersistentCookie = PersistLogin.Checked;
    string sReturnURL = FormsAuthentication.GetRedirectUrl(cookieUserName, createPersistentCookie);
                            FormsAuthentication.SetAuthCookie(cookieUserName, createPersistentCookie);
    
                            HttpCookie authCookie = Response.Cookies[FormsAuthentication.FormsCookieName];
                            authCookie.Secure = false;
    Since the 'affiliate banners' and the 'returned completed order' can return to any page,(outside our control) I've put some code in Global.asax and some in createaccount.aspx and orderconfirmation.aspx.

    Here's the issue:
    the relevant code in Global.asax is as follows---(this is after I collect the querystring vars)

    Code:
    //log the user back in
            string FixedCustomerGUID = Session["CBCustomerGUID"].ToString();
            FixedCustomerGUID = FixedCustomerGUID.Replace("{", "").Replace("}", "");
            FixedCustomerGUID = FixedCustomerGUID.ToLower();
            FixedCustomerGUID = FixedCustomerGUID.ToString();
            FormsAuthentication.SetAuthCookie(FixedCustomerGUID, true);
            HttpCookie authCookie = Response.Cookies[FormsAuthentication.FormsCookieName];
            authCookie.Secure = false;
    
            Response.Clear();
            
            //update this location to reflect the custom CB purchase procedure's needs
            Response.Redirect("orderconfirmation.aspx", false);
    THe problem is that when I'm building the SQL string for inserting th ecompleted order info into the relevant tables, ThisCustomer.whatever isn't filled in with the customer's data...

    I guess the question is, am I loggin them in right in Global.ASAX?
    FYI: I tried moving the code directly to the orderconfirmation page and get the same results...

    I am under the assumption that DNSF defines ThisCustomer via the GUID supplied in the .setAuthCookie portion of FormsAuthentication.SetAuthCookie(...

    Am I missing something to log someone in? Should I be using UserID? EMAIL?...

  2. #2
    bdamore is offline Member
    Join Date
    Jun 2011
    Posts
    52

    Default Solved: Fyi

    FYI: the global.asax loads several times and was resetting my session vars. I had to put in a check to look for a multiple loading condition and not overwrite my vars.

    fixed