Mysql is the most efficient way to store user agent, referral, etc.

What is the best way to store a user agent, referral, etc. on every page request so that I can track these actions for future statistics, etc.

Would it be better to store, for each user agent of the page request, referring to a new row in 1 or 2 tables?

would it be better to check if the user agent, referral, and if so then insert a new line?

+3


source to share


2 answers


I would recommend PHP Session, you can easily keep your info page within the page until they leave your site.

One page:

$_SESSION['userAgent'] = $_SERVER['HTTP_USER_AGENT'];

      



Second page:

if ($_SERVER['HTTP_USER_AGENT']!=$_SESSION['userAgent']){
echo 'User Agent Has Changed!';
}else{
echo 'User Agent Is The Same!';
}

      

+2


source


Chances are, your HTTP server is already capable of logging every request, including user agent, referral, and time. It would be more efficient to get the correct log parser than to constantly query the database.



0


source







All Articles