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

dommer's avatar
Level 1

Flush Livewire session property

Hi, I have a form property in my full page component:

#[Session(key: 'nomineeForm')]
public NomineeForm $nomineeForm;

It's a simple Livewire Form:

class NomineeForm extends Form
{
    #[Validate(['required', 'string', 'max:255'])]
    public string $name = '';

    #[Validate(['required', 'email', 'max:255', 'unique:nominations,email'])]
    public string $email = '';

    #[Validate(['required', 'string', 'max:255'])]
    public string $company_name = '';
}

Everything works fine, but I would like to clear this session after the form is submitted. I've tried adding the forget function to my submit method, but when I reload the page, the form is still prefilled and the session still exists:

session()->forget('nomineeForm');

When I add dd(session()->all()); after this forget line, I don't see my nomineeForm session, but when the page is reloaded, it's still there. I also tried session()->flush(); but got the same result.

0 likes
3 replies
Sinnbeck's avatar

Please show the submit action as well

dommer's avatar
Level 1

It's just simple method calling action and trying to clear session.

Here is the full livewire page.

And submit is fired from blade.

<form wire:submit.prevent="submit">
dommer's avatar
dommer
OP
Best Answer
Level 1

I figured out that there's no need to call session()->forget() or any other session-related methods. Simply calling reset() on the form object does the job:

public function submit(): void
{
    app(CreateNominationAction::class)->run(
        type: $this->type,
        nomineeForm: $this->nomineeForm,
    );

    $this->nomineeForm->reset();
}

Please or to participate in this conversation.