Jump to content

Record hit in Joomla based on Cookie Session


The Source

Recommended Posts

I currently have a website I am developing in Joomla 1.5.8

 

I need to limit the article views to 1 hit/User/Day eg

 

1:  User 1 views Article A and it records 1 hit in the DB

2:  User 1 views Article B and it records 1 hit in the DB

3:  User 1 views Article A again but it records no hit in DB because he already viewed it

 

I imaging this can be done by setting a cookie in the code that calls the content page and letting it expire the session after 24 hours.

 

I am just not sure how to go about this in Joomla

The only problem with using cookies is if the person deletes them.

 

I'd personally record each user's IP address in a mysql table, and the date they last viewed the article.

 

Then each time someone comes to view an article, check they haven't already seen it in the last 24 hours.

  • 2 weeks later...

just tag the username to the article, do a strpos scan for the username ( which is required to be unique ) and flush periodically as required.

 

Note that IP isn't reliable for this purpose, user may use another computer/location, but username remain a constant.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.