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

Hardie's avatar

Session value is not change

Hi, I want to change session value i.e. overwrite the session value.

Suppose my session array is like,

Array ( [_previous] => Array ( [url] => http://localhost/test ) [flash] => Array ( [old] => Array ( ) [new] => Array ( ) ) [_token] => asdfsda [language] => 3 )

Now by ajax call I want to change value of language, I tried session::put(), session::set() for overwrite value it works but when I refresh the page it display old value i.e. old array as above.

Please suggest or help same.

0 likes
3 replies
sid405's avatar

Before you make the Ajax call, where is the session getting the data for the language? How are you setting that?

Hardie's avatar

HI Sid,

Default I set session value as "1" i.e. default language is English.

I have one drop down of languages and on change I fired one script and ajax call I send data to controller and change the session value but not works.

sid405's avatar

@Hardie No i understand what are you trying to do. What i'm asking is how is the session populated before your Ajax call?

Can i see the controller? JS code for ajax request? Are you receiving errors in the inspector or laravel.log?

Please or to participate in this conversation.