2

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.

0

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;
    }

    $this-setData($this-_session-getVisitorData());
    $visitorId = $this-getId();
    if (!$visitorId) {
        $this-initServerData();
        $this-setFirstVisitAt(now());
        $this-setIsNewVisitor(true);
        $this-save();
    }

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

Seen config code

<events
    <controller_action_predispatch
        <observers
            <log
                <classlog/visitor</class
                <methodinitByRequest</method
            </log
        </observers
    </controller_action_predispatch
    ...

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.