I’m trying to understand cookie behavior in mautic and at first sight it wasn’t obvious. I understand there are a few cookies, namely:
mtc_id: id of the user
mautic_session_id: session id, and there is another cookie with this id that points to the user id
mautic_session_name: I don’t know what this is used for
The problem is that mtc_id seems to be sometimes set and sometimes not (at least in my case, I have a suspicion using https for the tracking js is making things a bit more challenging).
Question is: how can I get the id of the user (reliably) without an API call, just using cookies assuming CORS and cookie domain settings are fine. Shall I do an OR with $_COOKIE[“mtc_id”] or $_COOKIE[$_COOKIE[“mautic_session_id”]]?
–
Below is my search on the topic if anyone ends up here from a search.
I’m trying to understand cookie behavior in mautic and at first sight it wasn’t obvious. I understand there are a few cookies, namely:
mtc_id: id of the user
mautic_session_id: session id, and there is another cookie with this id that points to the user id
mautic_session_name: I don’t know what this is used for
The problem is that mtc_id seems to be sometimes set and sometimes not (at least in my case, I have a suspicion using https for the tracking js is making things a bit more challenging).
Question is: how can I get the id of the user (reliably) without an API call, just using cookies assuming CORS and cookie domain settings are fine. Shall I do an OR with $_COOKIE[“mtc_id”] or $_COOKIE[$_COOKIE[“mautic_session_id”]]?
–
Below is my search on the topic if anyone ends up here from a search.
<?php
// Currently tracked lead based on cookies
$leadModel = $this->getModel('lead');
$lead = $leadModel->getCurrentLead();
$leadId = $lead->getId();
Which I'm not sure about because I can't figure out what it does.
Any suggestions?
Are you working on a local installation? I also for the past year have been finding the mtc_id to be extremely unreliable; however, it’s mostly while working on my local installation.