spode Posted July 20, 2007 Share Posted July 20, 2007 Is there a function (or way) to see how many times a user has viewed a page during a session? I've been searching for quite a while and have come to a speed bump. Link to comment https://forums.phpfreaks.com/topic/60898-number-of-views/ Share on other sites More sharing options...
volatileboy Posted July 20, 2007 Share Posted July 20, 2007 set a session variable and increment it by 1 each time the page is loaded Link to comment https://forums.phpfreaks.com/topic/60898-number-of-views/#findComment-303033 Share on other sites More sharing options...
TheFilmGod Posted July 20, 2007 Share Posted July 20, 2007 Do you mean a single page. In your explanation you said a page. If so, the previous post wouldn't work since it would count each page view. We want a page - same page? Link to comment https://forums.phpfreaks.com/topic/60898-number-of-views/#findComment-303038 Share on other sites More sharing options...
benjaminbeazy Posted July 20, 2007 Share Posted July 20, 2007 this should work under most circumstances, you may have to look out for how you name pages session_start(); $pageCount = 'page_'.$_SERVER['PHP_SELF']; $parts = explode(".", $pageCount); $pageCount = $parts[0]; $_SESSION[$pageCount]++; echo "Number of pageviews this session: ".$_SESSION[$pageCount]; Link to comment https://forums.phpfreaks.com/topic/60898-number-of-views/#findComment-303040 Share on other sites More sharing options...
spode Posted July 20, 2007 Author Share Posted July 20, 2007 yep, that worked, thanks a lot Link to comment https://forums.phpfreaks.com/topic/60898-number-of-views/#findComment-303046 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.