Skip to content

Instantly share code, notes, and snippets.

@biplobice
Last active October 5, 2022 11:05
Show Gist options
  • Save biplobice/6d4a30af856f94b14c127fd678aa342b to your computer and use it in GitHub Desktop.
Save biplobice/6d4a30af856f94b14c127fd678aa342b to your computer and use it in GitHub Desktop.
A simple PHP script to delete expired auth type concrete cookies
<?php
use Carbon\Carbon;
defined('C5_EXECUTE') or die('Access Denied.');
/**
* @author: Biplob Hossain <biplob.ice@gmail.com>
*/
$db = app('database/connection');
try {
$results = $db->executeQuery(sprintf('SELECT * FROM authTypeConcreteCookieMap WHERE validThrough < %d', Carbon::now()->timestamp));
foreach ($results as $result) {
if (Carbon::createFromTimestamp($result['validThrough'])) {
echo t('Deleting the record with the ID: %d, Valid Through: %s', $result['ID'], Carbon::createFromTimestamp($result['validThrough'])->toDateTimeString()) . PHP_EOL;
$db->delete('authTypeConcreteCookieMap', ['ID' => $result['ID']]);
}
}
} catch (\Doctrine\DBAL\Exception $e) {
app('log/exceptions')->error($e->getMessage());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment