When does Magento decide to give a guest a new visitor_id? I noticed many entries in log_visitor table, and session_id often is replicated many times, and that makes cart get empty sometimes for some users.

1 Answer 1


Magento is give a guest visitor id whenever controller_action_predispatch event is fire first time for a visitor .

On controller_action_predispatch event magento trigger function initByRequest()

You can see the function at Class Mage_Log_Model_Visitor

public function initByRequest($observer)
    if ($this-_skipRequestLogging || $this-isModuleIgnored($observer)) {
        return $this;

    $visitorId = $this-getId();
    if (!$visitorId) {

    if (!$visitorId || $this-_isVisitorSessionNew()) {
        Mage::dispatchEvent('visitor_init', array('visitor' = $this));
    return $this;

Seen config code


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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