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

Chris1904's avatar

How to set a session timeout for a specific session?

Hi fellas!

I am currently struggling with this scenario:

I use Google Adsense and infinite load. Whenever I "load more" data on the page through AJAX, it automatically pulls in another ad from Google as well, which obviously is not displayed since Google does not support to bring in ads through AJAX.

I need help with the logic of how I can only show 1 ad on the load of the page and whenever the load more button is pressed, how to ignore the @include ('components.responsive_ad_display_only')

I currently thought about using sessions. I am using session()->put('retrieve', '1'); right after I include the ad. Then once "load more" is pressed, I check if the session is set. If it is set I am not including the ad while pulling in more data. The issue with this scenario is the fact that I need to "forget" the session eventually, so that when the visitor refreshes the homepage, a new ad would appear.

I would appreciate any help and direction towards solving my dilemma.

Thanks a lot!

0 likes
0 replies

Please or to participate in this conversation.