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

ToxifiedM's avatar

Why the session is storing key data as a string instead of number - Laravel Inertia Vue

I am currently storing perPage data in the sessions and partially loading the data based on the perPage value selected. The problem is, I have set my prop type as number, but when the perPage data is being stored in the sessions, it is being stored as a string. So it is throwing me an error in the console log.

Invalid prop: type check failed for prop "perPageData". Expected Number with value 10, got String with value "10".

How can I store the value in the sessions as a number and not a string? Help would be really grateful.

0 likes
3 replies
neilstee's avatar
neilstee
Best Answer
Level 34

@toxifiedm or you could quickly fix it by casting the session data to string or the other way around.

1 like
ToxifiedM's avatar

Thanks for the revert! Please can you explain how can I do that, down below is my current implementation of storing a value in the session whenever the value in the frontend changes.

public function updatePerPage(Request $request)
{
    session()->put('perPage', (int)$request->get('per_page'));
        
    return session('perPage');
}
ToxifiedM's avatar

The code I posted above with (int)$request->get('per_page') within the public function updatePerPage worked as a charm, thanks a lot for directing me to the right path!

1 like

Please or to participate in this conversation.