Skip to content

Cancel all active sessions

Payam Khaninejad edited this page Nov 29, 2016 · 6 revisions

If you want to cancel all active session by a timer or cronjob you can do just like this example:

"active"]; $pdo = new DBPDO(); $res = $pdo->fetchAll("SELECT * FROM `conversation` WHERE `status` = 'active' AND `updated_at` < '" . Carbon::parse('-15 minute')->toDateTimeString() . "' ", $update); foreach($res as $user) { $chat_id = $user["chat_id"]; $sql = "UPDATE `conversation` SET `status` = 'stopped' WHERE `conversation`.`id` =" . $user["id"]; $pdo->execute($sql); if ($chat_id !== '' && $message !== '') { $data = ['chat_id' => $chat_id, 'text' => $message, ]; $result = Request::sendMessage($data); if ($result->isOk()) { echo 'Message sent succesfully to: ' . $chat_id . "\n"; } else { echo 'Sorry message not sent to: ' . $chat_id . "\n"; } } } ?>