In Web2Chat, it's crucial to properly end a user's session when they log out of your application to ensure privacy and data security. This process clears any stored data and prepares Web2Chat for a new user session.
Steps to End a Session
- Initialize User Tracking:
- Ensure that you have already begun tracking your user via the Web2Chat JavaScript snippet or the
boot
method.
- Call the Shutdown Method Upon Logout:
- When a user logs out of your application, invoke the
Web2Chat('shutdown');
method from our JavaScript API. This action will end the Web2Chat session and clear any associated cookies.
- Start a New Session if Necessary:
- If applicable, you can initiate a fresh Web2Chat session by calling
Web2Chat('boot', {app_id: 'YOUR_APP_ID'});
. Remember to replace'YOUR_APP_ID'
with your actual Web2Chat application ID.
By following these steps, you ensure that Web2Chat resets to a clean state, ready for a new user or for areas of your application where users are not logged in.
Setting a Session Duration
Alternatively, you can specify a set time in your Web2Chat Messenger snippet using the
session_duration
parameter, after which the session cookie will automatically expire. This approach adds an extra layer of security by limiting the duration of active sessions.If you need further assistance, contact our Customer Support.