After a customer (who created an account) checks out, . . and they placed their order, . .
I want to write a "remember me" cookie.
So the next time they return, their Email address will be in the
"E-Mail Address : " field of the Login Page.
I tried making this "true" but it didn't work (from OnePageCheckout):
User.Migrate(oldUser, newUser, true);
Token.Instance.InitUserContext(newUser);
FormsAuthentication.SetAuthCookie(newUser.UserName, false); // true didn't work
Anyone know how I can do this?
Write a Remember Me cookie after Customer Checks out
Re: Write a Remember Me cookie after Customer Checks out
I am not sure where do you want to write your cookie.Already on log in Page a cookie is working to remember User Name usually email address.
This is the code to write a cookie
Place this on login/register Button click event
On Page Load place this code
This is the code to write a cookie
Place this on login/register Button click event
Code: Select all
HttpCookie EmailCookie = new HttpCookie("Email", EmailTextBox.Text);
EmailCookie.Expires = DateTime.MaxValue;
Response.Cookies.Add(EmailCookie);
Code: Select all
HttpCookie EmailCookie = Request.Cookies["Email"];
if (EmailCookie != null && !string.IsNullOrEmpty(EmailCookie.Value))
EmailTextBox.Text.Text = EmailCookie.Value;
hope this helps!
__________________
s_ismail

AbleCommerce Customization
Free Plugins and Add-Ons
AbleCommerce Plugins and Add-Ons
Plugables Blog
__________________
s_ismail


AbleCommerce Customization
Free Plugins and Add-Ons
AbleCommerce Plugins and Add-Ons
Plugables Blog
Re: Write a Remember Me cookie after Customer Checks out
AbleCommerce login page already have a remember me option. Did you tried that?
Re: Write a Remember Me cookie after Customer Checks out
That works only after the customer puts in their Email addressmazhar wrote:AbleCommerce login page already have a remember me option.
the first time they return to the site, after placing their first order.
From then on, the Email address will appear
The problem is when they return to the site after they placed their first order :
the Email address doesn't show in the box.
Re: Write a Remember Me cookie after Customer Checks out
I tried this and I think it works, . . added code at end (OnePageCheckout):
Now when the customer return, the Email Address appears in Log In email text box.
This will avoid a lot of confusion, and make it easier for returning customers.
Code: Select all
void CheckedOut(object sender, CheckedOutEventArgs e)
{
...............
//MIGRATE THE USER
User oldUser = Token.Instance.User;
string newUserName = oldUser.PrimaryAddress.Email;
string newEmail = oldUser.PrimaryAddress.Email;
string newPassword = NewUserPassword.Text;
if (!CreateAccountPanel.Visible)
{
anonCheckout = true;
newUserName = "zz_anonymous_" + Guid.NewGuid().ToString("N") + "@domain.xyz";
newPassword = Guid.NewGuid().ToString("N");
}
MembershipCreateStatus createStatus;
User newUser = UserDataSource.CreateUser(newUserName, newEmail, newPassword, string.Empty, string.Empty, true, Token.Instance.User.AffiliateId, out createStatus);
//IF THE CREATE FAILS, IGNORE AND CONTINUE CREATING THE ORDER
if (createStatus == MembershipCreateStatus.Success)
{
if (anonCheckout)
{
// CHANGE THE NAME AND EMAIL TO SOMETHING MORE FRIENDLY THAN GUID
newUser.UserName = "zz_anonymous_" + newUser.UserId.ToString() + "@domain.xyz";
newUser.Save();
}
User.Migrate(oldUser, newUser, true);
Token.Instance.InitUserContext(newUser);
FormsAuthentication.SetAuthCookie(newUser.UserName, false);
// ********* I ADDED THIS TO WRITE THE COOKIE ********************
if (!anonCheckout)
{
HttpCookie cookie = new HttpCookie("UserName", newUser.UserName);
cookie.Expires = DateTime.MaxValue;
Response.Cookies.Add(cookie);
}
}
}
......................
This will avoid a lot of confusion, and make it easier for returning customers.
Re: Write a Remember Me cookie after Customer Checks out
This worked, . . but change
if (!anonCheckout)
{....
to:
if (CreateAccountPanel.Visible)
{....
if (!anonCheckout)
{....
to:
if (CreateAccountPanel.Visible)
{....