Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should I do when users log out?

Tags:

I am setting Mixpanel up, and I found out that if I log in with a user (and identify that user), log out and then re-register as a new user, the new user's details overwrite the previously logged in user (presumably when I call alias). How can I tell mixpanel that a user has logged out and to reset the identity token (make it anonymous again)?

like image 817
fredley Avatar asked Jan 15 '14 12:01

fredley


People also ask

Why is it important to log out of accounts?

Logging out helps prevent other users from accessing the system without verifying their credentials. It also helps protect the current user's access or prevent unauthorized actions on the current login session and is thus an important part of security.

Should it be logout or log out?

Logout is a noun, to be used like so: "go to the logout screen". Log out is an action, to be used like so: "you need to log out". Because both are action buttons, they need to both be titled "Log Out."

How do I log a user out?

Quick tip: You can also use the Ctrl + Shift + Esc keyboard shortcut to open Task Manager. Click the Users tab. Right-click the user and select the Sign off option.

What is the difference between signing out and logging out?

Alternatively referred to as log, log off, and sign out, sign off is disconnecting from a network or account voluntarily. For example, to check your credit card balance, you log into your account. When you are done reviewing the information, you log out, which is the same as signing off.


2 Answers

I ran into the same issue, and after some sleuthing I discovered that you can manually clear the mixpanel cookies with mixpanel.cookie.clear().

However, you need to make sure that the mixpanel library has loaded, so I ended up putting it in a stupid timeout:

var id = window.setInterval(function() {   if (mixpanel.cookie && mixpanel.cookie.clear) {     mixpanel.cookie.clear();     window.clearInterval(id);   } }, 50); 

And then, since I didn't want to do this on every page, I added a query string parameter onto my logout redirect URL. So after visiting /logout it would redirect them to /home?_ref=logout, at which point I would clear the mixpanel cookie only if that query string parameter existed.

It was pretty annoying, but it seemed to work.

like image 122
tmont Avatar answered Oct 13 '22 11:10

tmont


It was released on Mixpanel Javascript version v2.8.0 the mixpanel.reset() function, so that's officially what should be called on user logout. See https://github.com/mixpanel/mixpanel-js/issues/67 .

like image 36
Ricardo Nacif Avatar answered Oct 13 '22 09:10

Ricardo Nacif