Question by Anup Kumar
i am working on a e-commerce website, i want to monitor how many pages a users visited in a particular session. there are only registered users of the site.
can any one tell me how to record the URL of the user of a particular session,
i am using php and mysql
Answer by Starx
There are more than one way to do this. Here is one quick walkthrough:
Create a table with two fields (‘session_id’, ‘url’);
Whenever the site loads, read the sessionid using
session_id(), and use this value to store the url of the page in a table for every pages the people visit.
Once a page loads, read the URL, through
$_SERVER['REQUEST_URI'];and then use it the value of
session_id()and store the records.
After you implement this simple technique. you can see how many people see the pages, using a simple query
SELECT count(*) FROM <YOURSESSIONTABLE> GROUP BY `<session_id_field>`
P.S. This is one of the basic example, and should be changed to fit your requirements