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

amitshrestha221's avatar

Retrieve session from Session ID

Hello all,

I need to retrieve session info using session ID, when I did


$session = session();
dd($session);

I got this random sesison ID EE7868eFef...

This file exists in storage/framework/sessions/____

I want the content of that file using sessionID. Because I need to access that session data using cron job.

0 likes
5 replies
Sinnbeck's avatar

That sounds like a weird idea. Can you explain what you trying to do? I am not saying it isn't possible. Just saying there probably is a better way

amitshrestha221's avatar

@Sinnbeck

The scenario is this:

  1. I am using a card package : https://github.com/bumbummen99/LaravelShoppingcart
  2. When user adds to cart, as per my requirement, I have to decrease the stock.
  3. The cart doesnt provide config to reset at 5 minutes.
  4. So, I am planning to remove cart from the session data located inside storage/framework/sessions___ file.
  5. I am trying to track user's session_id in a virtual table along with every cart add/update and then on basis of that session_id, I am trying to run a cron job, which upon created every 5 minutes, IF NOT COMPLETED THE ORDER, will remove cart data from the user's session file based upon that same session_id.
amitshrestha221's avatar

@fylzero Yes sir, when the cart package allows us to expire the cart on logout and I have restocked the cart during logout. Upon new sign in, the cart is auto initialized to NULL.

I wanted to remote cart from active session of the user, so that the user doesn't have to login every 5 minutes.

Please or to participate in this conversation.