Force Session Logout

I have made my PHPMaker project for Concurrent Login of 3, which means at a time 3 session can be login from 3 different device.Now I would like to give a option to my user to logout from all the session at a time.
i.e.

  1. Logout - To logout the current session only.
  2. Logout from all - To logout all the session.
    (Which means all the user has to put the username and password again to access the site.)

Why don’t you enable “Reset concurrent user session count” option from “Security” → “Advanced” → “User Login Options” → “User Table List Page Options”, and then re-generate ALL the script files again?

I also have a similar situation. I have “disallow concurrent login” enabled. But I would like to know if is possible when a user logs in to logout the other session via the “memo” column in the user table as opposed to the default behavior of showing the “user xxx already logged in” message. Is there any easy way to do this or would I have to do it the long way ie open memo field → convert from json to array → delete relevant key/index → update field. Thanks.

Assume you’re using v2020, try this (it actually in which event did you want to run this code?):if (!isset($UserProfile))
$UserProfile = new UserProfile();$UserProfile->loadProfileFromDatabase(CurrentUserName());
$UserProfile->Profile[Config(“USER_PROFILE_SESSION_ID”)] = “”;
$UserProfile->Profile[Config(“USER_PROFILE_LAST_ACCESSED_DATE_TIME”)] = “”;
$UserProfile->saveProfileToDatabase(CurrentUserName());

Very Interesting topic.
Have anyone find the solution then please share

I want to forcefully logout my client from my end. The client username is “10589”
And try the above code
if (!isset($UserProfile))$UserProfile = new UserProfile();
$UserProfile->loadProfileFromDatabase(“10589”);
$UserProfile->Profile[Config(“USER_PROFILE_SESSION_ID”)] = “”;
$UserProfile->Profile[Config(“USER_PROFILE_LAST_ACCESSED_DATE_TIME”)] = “”;
$UserProfile->saveProfileToDatabase(“10589”);

As per the above code the user profile database is change and the session id goes to blank.
But still when my client try to browse it is working. And when i check the profile database the session id automatically enter.

After running the above code I would like my client to re-login again.
That means he has to put his username and password again.

Try to remove all the content of “Profile” field in your “users” table that belongs to your desired user(s).

I have remove all the content for the particular user.

But the client is able to access the website without relogin again.

You may actually do the following trick to force session logout for your end-users:

  1. Create a new field in your “users” table, and name it, for example, as “Force_Logout” (enum field type, with “Y” and “N” options; by default it is setup to “N”)

  2. Write your PHP code in “Page_Rendering” server event in order to check the value of this field for the current user logged in, and if it is equal to “Y”, then call CurrentPage()->terminate(“logout.php”); to force your end-users to be logged out.

thanks ur trick works.

I have made a concurrent user login to 1
A client is login from a computer 1
A client again try to login from a Computer 2 without logout from the computer 1
it says User already login.

Now in my condition I want as
If A client is login from a computer 1
and again if a client is trying to login from a computer 2 without logout from the computer 1
then he should allow to login in computer 2 and it should automatically logout from the computer 1

Then you need to clear the user session from the Profile field of your users table when your user is trying to login from computer 2, after that write your script to redirect him/her to logout.php page, and then display the message to try to login again.

mobhar wrote:

You may actually do the following trick to force session logout for your end-users:

  1. Create a new field in your “users” table, and name it, for example, as
    “Force_Logout” (enum field type, with “Y” and “N”
    options; by default it is setup to “N”)

  2. Write your PHP code in “Page_Rendering” server event in order to check
    the value of this field for the current user logged in, and if it is equal to
    “Y”, then call CurrentPage()->terminate(“logout.php”); to
    force your end-users to be logged out.

I don’t understand… What would be the automatic way to make the CCC variable return to N after the user has closed all sessions?

It actually depends on your needs. For this case, you may write the code to update the “Force_Logout” field back to “N”, before the line that contains redirecting to logout.php.

If we do it that way, the variable would return to N after the first session logs out, and the other sessions on other devices would no longer be disconnected because they would find the variable in N again. Or would they?

If user has been logged-out by system, then the other device that still the same user should not be able to continue again, since the session has been removed/destroyed from the user profile field.

mobhar wrote:

Assume you’re using v2020, try this (it actually in which event did you want to run
this code?):> if (!isset($UserProfile))
$UserProfile = new UserProfile();> $UserProfile->loadProfileFromDatabase(CurrentUserName());
$UserProfile->Profile[Config(“USER_PROFILE_SESSION_ID”)] = “”;
$UserProfile->Profile[Config(“USER_PROFILE_LAST_ACCESSED_DATE_TIME”)] =
“”;
$UserProfile->saveProfileToDatabase(CurrentUserName());

Where do I put this code
Or what is the method of disabling : User ‘’ is already logged in!

saleh wrote:

Where do I put this code

mobhar wrote:

(it actually in which event did you want to run this code?)