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.
There is a very old thread at: https://www.mautic.org/community/index.php/82-how-can-i-use-the-mautic-api/0#p536 on the topic but it’s so old I can’t rely on it.
has some php code
// 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.