rianto isaac's Weblog

rianto utomo isaac sahala utomo

php, ip address browser screen resolution

leave a comment »

<?php
//IP
echo “<hr><p>about you :”.”<br>”;
echo “IP1 = “.$_SERVER[‘HTTP_X_FORWARDED_FOR’].”<br>”;
echo “IP2 = “.$_SERVER[‘REMOTE_ADDR’].”<br>”;
//browser
echo “Browser = “.$_SERVER[‘HTTP_USER_AGENT’];
//resolusi
if(isset($_COOKIE[“device_resolution”]))
$screen_res = $_COOKIE[“device_resolution”];
else //cookie is not found set it using Javascript
{
?>
<script language=”javascript”>
<!–
checkScreenWidth();

function checkScreenWidth()
{
var exdate=new Date();
exdate.setDate(exdate.getDate() + 365);
var screen_width =  screen.width +”x”+ screen.height;
var c_value=screen_width + “; expires=”+exdate.toUTCString();
document.cookie= ‘device_resolution=’ + c_value;
}
//–>
</script>
<?
}

echo “<br>Screen Resolution = “. $screen_res;
echo “</p>”;
?>

Written by isaaconi

Juli 17, 2013 pada 10:53 am

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s

%d blogger menyukai ini: