jbcedge
jbcedge

Reputation: 19505

getting total no of viewers in php

Im developing a site, i want to know how can i track who has viewed the profile of particular users, registered users or visiters. Site is developed in php.

Any sugesstion please.

Upvotes: 0

Views: 112

Answers (3)

Ben Usman
Ben Usman

Reputation: 8387

Probably I've understood something wrong, but it seems to be something like this.

Em... First question, I think should be asked - all of pages visitors are definitely aut.? (I mean, is it necessary to authorization to get this profile data).

So, if all of them are definitely aut., you can just take something, defines this user (id or something else) and add it to special field of this profiles DB record (or anywhere else).

Or you can add (for example if you have to remember 10 last visits) 10 fields and a kind of "first pointer" - a number which tells you from which of this field you should start (like this:

... | 1rv | 2rv | 3rv | 4rv | 5rv | 6rv | fp |

234 432 432 432 32 234 5

if means, you should start from 5th - show contents of 5rv 6rv 1rv 2rv 3rv 4rv 5rv 6rv

and when something changes you just fp++, and write to fp's field...

It should work really good with mass of data, I think...

PS or you can inc. performance by crating an every user's pattern of "visit" message - I mean: you have feild "how message of my visit 'd look like", you just paste where you need it...

Upvotes: 1

Jan Krüger
Jan Krüger

Reputation: 18530

Well, whenever you generate a page that you want to track stuff for, collect whatever you need from $_SERVER, $_SESSION etc. and append it to a database table or something like that. You can then write a fancy analysis tool that creates awesome statistics from that data, or whatever else you wanted to use the data for.

Upvotes: 1

prodigitalson
prodigitalson

Reputation: 60413

Thats a very broad question... With lack of specifics something like this:

  • Store the user_id in a session variable
  • Everytime a user goes to a profile page update the appropriate related record to the profile with the user_id from the session.

Upvotes: 1

Related Questions