It is required to have some session variables set when customer visit store for first time, or his session was expired and renewed.

For existing customer it is possible to listen to customer_customer_authenticated event and when customer logs in - and add variable to core/sessionsingleton with observer, but how to deal with the guest user (or new registered customer ) ?

The main goal is to set some session variables when customer session is initiated, if the customer visits store for the first time, or its session was expired and reinitiated.

( From this session variables some layered filter defaults will be set, if the guest customer - one filter, if logged in - another filter - based on attributes of this customer, etc. But if session exists for him, let him to customize his layered filters in catalog area. )

How to accomplish this task ?


1 Answer 1


You can use visitor_init event defined in Mage_Log_Model_Visitor.

Just create an observer on it and grab the session:

<?xml version="1.0"?>

And in your observer:

class My_Module_Model_Observer {
    public function visitorInit($observer) {

I would suggest you to use core/session rather than customer/session for what you need to do. custoemr/session will be erased after login/logout.

Hope it helps.

  • Thank you Riccardo, this is exactly i was looking for !!!
    – Ilja
    Apr 25, 2016 at 19:28
  • You are welcome ;) Stack Exchange is here for that ;) Apr 25, 2016 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.