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

ncltours's avatar

cannot set session value .

$hotelSessionId = $api->hotelId; (which contains Id from 3rd party api)

Session::put('hotelSessionId', $hotelSessionId);

I am unable to set hotelSessionId. It gives empty value;

0 likes
2 replies
lostdreamer_nl's avatar

If this is inside a routes/web.php route (routes/api.php does not handle sessions) this should be working.

As long as you return something in the method that sets the session value, if it does an exit; or die or anything else, the session wont be set.

$hotelSessionId = 4;
Session::put('hotelSessionId', $hotelSessionId);

$hotelSessionTest = Session::get('hotelSessionId');
dd($hotelSessionTest);
ncltours's avatar

HI

My $hotelSessionId = "1DSLGJf9LPwmklaGaZvLIDal" which genrates from 3rd paty api.

It still gives null value.

Please or to participate in this conversation.