CosminStan Posted October 25, 2012 Share Posted October 25, 2012 Hello guys, i want to make a script that can show me (the user) the 5 visited last links on my website. Not sure if php is teh correct language to do this but i do not know how coockies work. Quote Link to comment Share on other sites More sharing options...
MDCode Posted October 25, 2012 Share Posted October 25, 2012 (edited) Cookies would only affect the user browsing, simply create a database. When a user views the page record it in the database. Check how many links the user has visited. If it is 5, delete the first record and record the next. Simple Btw, if this is in the third party section, where is the code you're using? Edited October 25, 2012 by ExtremeGaming Quote Link to comment Share on other sites More sharing options...
Christian F. Posted October 25, 2012 Share Posted October 25, 2012 Just use an array saved in the session, no need to make it more complicated than that. Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 26, 2012 Share Posted October 26, 2012 OP wants to know the last 5 links OTHER people clicked on, when they visited HIS site. Quote Link to comment Share on other sites More sharing options...
Christian F. Posted October 26, 2012 Share Posted October 26, 2012 Hmm... Hard to say, the OP is quite lacking on details. Could be, now that you've made me aware of it, Jessica. If that is indeed the case: Not going to happen. Unless you are Facebook or Google, and can convince every web developer to put your tracking code on their site. Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 26, 2012 Share Posted October 26, 2012 Christian, are you serious? You actually can't think of a way in PHP to track what links are clicked on your own website? *eyeroll* I do this on my sites, my Wordpress blog does it for me on my blog, etc etc. OP: Please come back and clarify. Quote Link to comment Share on other sites More sharing options...
Christian F. Posted October 26, 2012 Share Posted October 26, 2012 Ah, seems I misread you. Somehow I managed to read "OTHER sites", not "OTHER people". >< Sorry about that. That said the context of your first post is a bit confusing, as the two previous posts give a (rough) outline of how to track the links the users click on while on his site. Think you could be so kind as to explain it a bit further? Quote Link to comment Share on other sites More sharing options...
Jessica Posted October 26, 2012 Share Posted October 26, 2012 the two previous posts give a (rough) outline of how to track the links the users click on while on his site. Think you could be so kind as to explain it a bit further? Really? No, only one of them does. Cookies would only affect the user browsing, simply create a database. When a user views the page record it in the database. Check how many links the user has visited. If it is 5, delete the first record and record the next. Simple This, except don't delete anything, just store it. We also don't know if the OP wants to record outgoing links as well which would require more work. Just use an array saved in the session, no need to make it more complicated than that. How do you think that would do what I'm describing? It doesn't... Quote Link to comment Share on other sites More sharing options...
Christian F. Posted October 26, 2012 Share Posted October 26, 2012 Could probably have explained it in more detail, but this is what I was thinking of: <?php // Quick example, without any error checking. $_SESSION['links'] = array ( 5 => $_SESSION['links'][4], 4 => $_SESSION['links'][3], 3 => $_SESSION['links'][2], 2 => $_SESSION['links'][1], 1 => $_SERVER['PHP_SELF'], ); Upon re-reading the OP, I think I might have misunderstood him as well. Guess I was more tired than I thought last night. Again, sorry about that. Quote Link to comment Share on other sites More sharing options...
CosminStan Posted October 27, 2012 Author Share Posted October 27, 2012 (edited) Thanks guys, as i said i do not know anything about cookies or sessions, so i can't explain in more details ) soryy But thanks @Christian F for this quick intro, ho to solve this problem. I don't need any out goid links, just the ones that the user click on my website to be shown in a recent activity without the user to be logged in. Edited October 27, 2012 by CosminStan Quote Link to comment Share on other sites More sharing options...
MDCode Posted October 27, 2012 Share Posted October 27, 2012 Without a user being logged in makes it much more difficult and practically impossible unless you record all of their information, which, if you record ip those using the same isp could be mistaken as others. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.