Home » responsive-design » Server side responsive with cookies

here is code which i done after searching over google with help of different website.

<script type="text/javascript">
		function setCookie(cname,cvalue,exdays)	{
			var d = new Date();
			d.setTime(d.getTime()+(exdays*24*60*60*1000));
			var expires = "expires="+d.toGMTString();
			document.cookie = cname+"="+cvalue+"; "+expires;
		}
		windowwidth = document.body.clientWidth;
		setCookie("wwidth",windowwidth,30);
		var user1=getCookie("wwidth");
		//alert('user1'+user1);
		</script>
		<?php $screenWidth = $_COOKIE['wwidth'] ?>

Condition php code

<?php if ($screenWidth <= 660) { ?>
		<div class="class1" id="content">
	<?php } else { ?>
		<div class="class2" id="content">
	<?php } ?>

Array ( [0] => responsive-design, serverside )

Leave a comment

0 Comments.

Leave a Reply

You must be logged in to post a comment.