So this is my first time taking the OO approach to PHP and I'm not finding it easy. A few things are confusing me but here's the scenario I'm stuck with right now...
I want to track the popularity of a page by telling how many times it has been viewed.
The integrity of the statistics may be damaged by guests refreshing the page or visiting it more than once.
My solution? Record the ID of the pages the guest has viewed in an array stored as a $_SESSION value - when the guest visits a page check the array for the ID, if it's not there increment the view count of that page by one in the database and add the id of it to the array held in the $_SESSION value.
Now my problem is one of design and apologies if this should have gone in the Program Design forum. What should I do?
[*]Declare the session var and create/manipulate the array in the main body of the code.
[*]Declare the session var in the main body of the code and manipulate the array in a class, e.g. statsClass.php
[*]Declare (and name) the session var in the class
Also if I choose option 3 do I :
A) choose the name of the session var in the main code and pass it in my method call?
B) just choose the name of it in the class so it is always the same
I'm soooooooooooooooooooo confused D: I would love to get comfy with this OOP stuff but real world applications are never as simple as the examples provided in tutorials.
Any help is greatly appreciated, also if you operate a non-commercial site I'll throw you a link on a 'friends' list when my site is eventually done.
Cheers,
Pedro!