Mautic Community Forums

Delete cookies on mautic after logout

I am using Mautic with my website where I have a login and logout functionality. I want to clear all the cookies after logout so that when next user comes, it stops tracking the previous user and create a new one

Hi @namratasaun, have you found a solution for this?

On logout try clearing the following cookies:


If it does not work, report your findings and we can investigate it further.

He wants to do it programatically. The same pc is used by many people.

How to do this programmatically depends highly on which system is used for login & logout function. But the general idea is the same - you have to delete the old cookies before Mautic tracking script is fired when new user logs in.

The following three lines should delete cookies in PHP (this should be called during logout process)

setcookie('mautic_device_id', '', -1, '/', '', true, false);
setcookie('mtc_id', '', -1, '/', '', true, false);
setcookie('mtc_sid', '', -1, '/', '', true, false);

Without testing how this behaves in practice I cannot say if this works or not. However I am interested in solving this if @namratasaun you do not have the technical know-how I would be interested to look this into more detail for you.

I am not sure if this approach is helpful in my case. When running my website under and loading the tracker from, deleting cookies from the domain is not possible when logging out on

I would have to test it to be sure, but as far as I know mautic sets cookies via client side (JS). for the domain you are tracking not the domain Mautic is cumming from. If you look into Mautic cookies in your browser you should see they are set on (it depends how you Mautic tracking script is set).

Lastly, even if what I said is not true, you should still be able to achive this, by redirecting to at the end of your logout process on

In clear.php you say that you want to delete all mautic cookies and then redirect back to or something. But I would start with first suggestion as the second one is a bit odd.

The first suggestion would not work because as the docs mention the cookies set under are not used for tracking, but can be used for accessing the contact id and integrate with the API further.
The second suggestion would involve some custom implementation on Mautic, right @mzagmajster?

Yes, on Mautic side you need a script to clear cookies, I think the easiest approach is to start with simple php script that clears Mautic cookies and redirect back to

If it turns out that in practice this does not work, I would try to do the same by actually writing custom plugin and deleting tracking info via Mautic core functions.