Magento – Extending session / cookie lifetime for customers (Amazon-style)

cookiefrontendmagento-1.7session

When visiting Amazon, I've noticed that I always get greeted by name:

enter image description here

However, when I try click onto my account, it forces me to log-in again. I'm not 100% sure about the logic here, but I'm assuming they're identifying me by cookie.

This is really useful because it allows you to target specific products to specific customers based on their order history, like this:

enter image description here

How is it possible to identify customers who aren't logged in by cookie? Is it possible to set up a similar behaviour to Amazon?

Do I just need to extend the cookie lifetime? I'm not very familiar with this aspect of Magento.

Best Answer

I agree with what Cags states Persistent Cart is probably the closest thing to what your describing so the short answer would be no its not possible out of the box.

However, you could look into extending the functionality a little. Create a module which observes the event customer_login

As you might expect this would be used when a customer logs in, from this you could then create some abstract cookie to set their name.

The same module would also need to check for the customer_logout since this action would be triggered when someone actually logs out you can use it to destroy your created cookie which would have its own lifetime separately from the Magento sessions.

This would then allow you in your template files (or perhaps via a suitable helper) to retrieve the contents of your cookie and display their name similar to how Amazon keeps you logged in by its name cookie.

I do not recommend you put anything into the cookie which could be potentially used to identify the customer ID itself however.

Related Topic