0

I've got a basic, default install of Laravel with Breeze running. I want to be able to load the session data from a PHP script that is not running Laravel.

I'm using the 'file' SESSION_DRIVER. I can see the session files in framework sessions. For example the current session I have has a filename of b8lsMW3mjyszDIErNd2aP4SSblt01tStwdCCxzLD. I can see the data I want to get serialised in the file.

When my (non Laravel) script runs, I can read the 'laravel_session' cookie, it has a value of laravel_session:"eyJpdiI6ImVjQkYvWWhQSlZZYUdVNk55Y0R5OFE9PSIsInZhbHVlIjoidG0xeWFjdXR3U3M0cEl2RzBVZnZ1YzZCcFlPVFVXNVNIbmM4YTRNdnZSWmcrUi83NUlXTmF5QXpRS1ZoeGd6Y01PeFdoYVliQXBvQ3lZOGhPdHltWVdURUZON3pxUkdIQ2hxLzBIcVZuMVRnTm5NMmdsT2cwV1ZlRk02OTQ2bjQiLCJtYWMiOiJlNWQzN2RjNDhmYTRhNDYxZDY4NzM0NmY5MjY2MDMwMGZkZGM4MzEzMTc1OTc1ZDA5ZWY0MzcxZGExMjZhYTYyIiwidGFnIjoiIn0%3D"

What I cannot understand is how, from the value in the laravel_session cookie I can calculate the filename of the correct session to load.

Al_
  • 2,479
  • 7
  • 29
  • 43
  • Does this answer your question? [Share session data between another PHP application and Laravel](https://stackoverflow.com/questions/48780843/share-session-data-between-another-php-application-and-laravel) – miken32 May 03 '23 at 21:26
  • Don't use session data. Use a cache like Redis or similar. – miken32 May 03 '23 at 21:27
  • no that link doesn't answer the question as it's using Laravel functions. – Al_ May 03 '23 at 21:29
  • I can't use a cache, although I think I will face the same issue there. I've tried using the database session driver but this has the same issue the value used in the cookie does not match the session id stored in the database - the cookie value is different and much longer – Al_ May 03 '23 at 21:30
  • 1
    the cookie's value is encrypted ... you can take the value, 'url decode' it then you can decrypt it to get the session id – lagbox May 04 '23 at 00:08

0 Answers0