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

nikocraft's avatar

put a string in a session, session value gets saved as an array

I did this in my code

Session::put('image-'.'uploads/2016/11/25/15/abcd5.jpg', 'uploads/2016/11/25/15/abcd5.jpg');

then I did

        $session = Session::all();
        dd($session);

and got this

"image-uploads/2016/11/25/15/abcd5" => array:1 [▼
    "jpg" => "uploads/2016/11/25/15/abcd5.jpg"
  ]

why does value get saved as an array instead of a string, when I am using put and inserting a string and not an array?

Now I have problem accessing image path since I do not know if it's png, gif, jpb etc

0 likes
0 replies

Please or to participate in this conversation.