从python中销毁会话,执行php脚本

I created a python script for managing a multi tenant system on my server. The goal is to log out user sessions through the same script in python, executing a PHP script like this:

log_out_users.php

<?php

session_start();

session_unset();

session_destroy();

?>

with this Python code:

import subprocess

command = "php /var/www/tenant/log_out_users.php"
subprocess.call(command, shell=True)

The script runs correctly, but the session is not destroyed. It doesn't even work if I call the php file from CLI, entering into the tenant folder and running the command

php log_out_users.php

Any hints?

I solved it by denying access to users via .htaccess, in this way.