forked from doppar/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClearSessionCommand.php
More file actions
44 lines (37 loc) · 979 Bytes
/
ClearSessionCommand.php
File metadata and controls
44 lines (37 loc) · 979 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Phaseolies\Console\Commands;
use Phaseolies\Console\Schedule\Command;
class ClearSessionCommand extends Command
{
/**
* The name of the console command.
*
* @var string
*/
protected $name = 'session:clear';
/**
* The name of the console command.
*
* @var string
*/
protected $description = 'Clear all sessions from the Applicaion.';
/**
* Execute the console command.
*
* @return int
*/
public function handle(): int
{
return $this->withTiming(function() {
$sessionDir = base_path('storage/framework/sessions');
$files = glob($sessionDir . '/*');
foreach ($files as $file) {
if (is_file($file)) {
@unlink($file);
}
}
session()->flush();
return Command::SUCCESS;
}, 'Application sessions have been gracefully cleared.');
}
}