heldercervantes Posted December 20, 2017 Share Posted December 20, 2017 Hey. What would be a clever way of detecting if the page being rendered is the first viewed in a session? Think landing page. In fact, think blog article. I want to put a CTA there that would appear only if the user just landed directly in that page. But if the user came from, i.e., the homepage, I want it to behave differently. Any ideas? Thanks, H Link to comment Share on other sites More sharing options...
DaveP Posted December 20, 2017 Share Posted December 20, 2017 if(!$session->get('flag'){ echo 'New visitor'; $session->set('flag'); } else { echo 'Been here a while'; } Completely untested but can't think why it shouldn't work. 1 1 Link to comment Share on other sites More sharing options...
rick Posted December 20, 2017 Share Posted December 20, 2017 A user going directly to a page is either from a bookmark or typing (pasted) url. So you could check both the referrer and bookmarks on the desired target page(s). Otherwise you'd have to test and set a result (as @DaveP shows) on all non-target pages, then test for that result on all target pages. Link to comment Share on other sites More sharing options...
heldercervantes Posted December 20, 2017 Author Share Posted December 20, 2017 HAH! Of course! That will definitely work. 1 Link to comment Share on other sites More sharing options...
dragan Posted December 20, 2017 Share Posted December 20, 2017 Or, you could set cookies (completely client-side) instead. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now