<?php
if
( isset(
$_COOKIE
[
'orientation'
]) ){
$rotation
=
$_COOKIE
[
'orientation'
];
if
(
$rotation
== 0 ){
echo
'<h1>Is Portrait</h1>'
;
}
else
{
echo
'<h1>Is Landscape</h1>'
;
}
}
else
{
?>
<script type=
"text/javascript"
language=
"javascript"
>
function
writeCookie(){
the_cookie = document.cookie;
var
orientation = 0;
if
( window.orientation ){
orientation = window.orientation;
}
the_cookie =
'orientation='
+window.orientation+
';'
+the_cookie;
document.cookie = the_cookie;
document.location =
'<?=$_SERVER['
PHP_SELF
']?>'
;
}
document.body.addEventListener(
'orientationchange'
, writeCookie );
writeCookie();
</script>
<?php
}
?>