check user details on the webapp

i need help with this: when a user/visitor visits my webapp, and clicks one of my page Test System Requirements, it should detect the following:

  1. the user’s Operating System

  2. the user’s Browser

  3. the user’s media player, [could be WMP’s current version in user’s computer]

  4. if user’s cookies are enabled.

  5. if user’s javascript is enabled.

any help would be greatly appreciated. thank you.

for detect javascript, you can write a simple function that make a redirect, so if you have a request from the redirected url, you know that js is enabled, the same for cookies.

The user browser identificator is available in $_SERVER[‘HTTP_USER_AGENT’]. In the user agent is also written the operating system, but not in a standard way, you should hack the string you receive for get it.

About media player I have no ideas.

yeah, about that. i need to display the details in the page… so if i redirect, … i mean is there any way for the webapp to confirm that?? just simply to know if cookies and jvascrpt are enabled. thank you

Actually, Yii should give all user a cookie, named PHPSESSID.

You can check if this cookie is in $_COOKIE, if not it means that the browser has the cookies disabled.

About javascript, you can create your link like that:




<?php echo Chtml::link(

	'system check', 

	array('syscheck', 'javascript'=>'no'),

	array( 'onClick'=>'{location.href = "'.CHtml::normalizeUrl( array('syscheck', 'javascript'=>'yes')).'"; } return false;')

);?>




If javascript is enabled, you will be redirected by javascript to the page syspage&javascript=yes, otherways the browser will follow the link to syspage&javascript=no. You can check $_GET[‘javascript’] for know wether js is enabled.