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

Ligonsker's avatar

When using dd(), the session is not being extended

Hello,

I set the session lifetime to the minimum of 1 minute for testing purposes. In one of the controllers in the index() method, I simply dd() some data.

I noticed that even if I constantly refresh the page in that minute, it won't extend the session, as if the request never gets to the part that extends the session. and when a minute passes, the user is logged out (even though I refreshed the page non-stop)

Why? I thought that until it reaches the controller method it also passes through the part where it extends the session and the user should continue to be logged in even when using dd().

(When I remove the dd() and keep refreshing the page, the user is not logged out)

Thanks

0 likes
3 replies
Snapey's avatar
Snapey
Best Answer
Level 122

AFAIK the session data is only persisted at the end of the request cycle.,

  1. Session is loaded into memory at the start of the request
  2. your application makes necessary changes to the user's session
  3. end of the request cycle, the user's session is written back to permanent memory

When you dd somewhere in step 2, you terminate the request without running any of the terminable middleware and so step 3 is never processed.

1 like
Ligonsker's avatar

@Snapey awesome, got it. I just thought that it happens some when at the beginning.

If I need to dd some data and finish the cycle, what should I do? Use the Log facade?

Please or to participate in this conversation.