Session attribute on Collection property dont work with default json session serialization
Author: marcheffelsCreated Apr 28, 2026Updated Jul 4, 2026
Livewire version
v4.2.4
Laravel version
v13.6.0
PHP version
8.3.30
Browser and operating system
Firefox on Arch Linux
Describe the issue you're experiencing
For new applications, JSON is now the default config for session serialization. laravel/laravel@75cef50
The #[Session] attribute on a Collection property will throw an error because JSON serialization turns the collection data to an array.
Code snippets to reproduce the issue
<?php
use Illuminate\Support\Collection;
use Livewire\Attributes\Session;
use Livewire\Component;
new class extends Component {
#[Session]
public ?Collection $list = null;
public function mount(): void
{
if(is_null($this->list)) {
$this->list = collect();
}
}
public function add(): void
{
$this->list->push(random_int(0, 100));
}
};
?>
<div>
<button wire:click="add">Add</button>
<p>{{ $this->list->implode(', ') }}</p>
</div>Screenshots/screen recordings
How do you expect it to work?
Ideally, Collections should also work with JSON serialization. Otherwise, a note in the documentation that session serialization must be changed to "php" in the configuration file when using Collections would be very helpful.
Please confirm (incomplete submissions will not be addressed)
- I have provided easy and step-by-step instructions to reproduce the bug.
- I have provided code samples as text and NOT images.
- I understand my bug report will be removed if I haven't met the criteria above.
Source: livewire/livewire