Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

anthonymau's avatar

Strange session outputs

Fresh install of Laravel 10 with Jetstream/Livewire (today, nothing else changed/added).

When I echo $session->agent->platform() once, it comes out as expected ("OSX").

When I do it a second time in the same blade template, the second time comes out as "1"

This also causes an issue in a @if, e.g.

@if($session->agent->platform()) {{$session->agent->platform() @endif, outputs 1. If I pull it outside of the if it outputs "OSX" again. If I put it before, in and after the if, I get "OSX", "1", "1".

I had this issue on an existing project when I upgraded so I thought it was something I had done. But unfortunately, I'm having the same problem with a fresh install.

It's like the variable is somehow corrupted after the first output.

0 likes
3 replies
anthonymau's avatar

@Snapey I assume it's coming from here:

vendor/laravel/jetstream/src/Http/Livewire/LogoutOtherBrowserSessionsForm.php

public function getSessionsProperty()
    {
        if (config('session.driver') !== 'database') {
            return collect();
        }

        return collect(
            DB::connection(config('session.connection'))->table(config('session.table', 'sessions'))
                    ->where('user_id', Auth::user()->getAuthIdentifier())
                    ->orderBy('last_activity', 'desc')
                    ->get()
        )->map(function ($session) {
            return (object) [
                'agent' => $this->createAgent($session),
                'ip_address' => $session->ip_address,
                'is_current_device' => $session->id === request()->session()->getId(),
                'last_active' => Carbon::createFromTimestamp($session->last_activity)->diffForHumans(),
            ];
        });
    }

Please or to participate in this conversation.