skip to Main Content

Track the last activity in laravel

In laravel auth middleware i create session variable and store the the last entering time like class Authenticate extends Middleware { public function handle($request, Closure $next, ...$guards) { if (auth()->check()) { session()->put('activity_time', now()->toDateTimeString()); } return parent::handle($request, $next, ...$guards); } protected…

VIEW QUESTION

Sessions in PHP do not get destroyed and cookie is not removed

I have this function logout that gets called before the HTML is rendered and it is: function logout() { $_SESSION = []; if (ini_get("session.use_cookies")) { $params = session_get_cookie_params(); setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"] ); } session_destroy();…

VIEW QUESTION

PHP Session Language switch

I'm using quite a simple and straightforward session switch to make my site bilingual. However it has a flaw - as soon as you switch to the other language, it throws you back on the index. I would like to…

VIEW QUESTION

How to update Laravel session Id in testing

How can I make the get request load with its session id as what is initially created with $sessionId = session()->getId(); public function test_chatbot_messages_page_has_non_empty_chat(): void { $sessionId = session()->getId(); ChatbotMessage::create([ 'session_id' => $sessionId, 'content' => 'Hello', 'role' => 'You', ]);…

VIEW QUESTION
Back To Top
Search