PHP implements cookie skinning method, PHP implements cookie skin
The example in this article is about how PHP is implemented with cookie skinning. Share to everyone for your reference. Specific as follows:
The savestylesheet.php page is as follows:
<?php function StyleSheet ($currentCookie) {//Get current Style Sheet $currentCookie = $_cookie[" StyleSheet "]; Get New Cookie file name switch ($_get[' style ') {Case 1: $value = ' style1.css '; Break Case 2: $value = ' style2.css '; Break Case 3: $value = ' style3.css '; Break Default: $value = ' style.css '; Break }//If The User views this page, without using//style= ... then set cookies to the default If (!isset ($_get[' style ') ) {$value = ' style.css '; }//If the new value doesn ' t equal the old value to allow cookie change If (isset ($value) | | $currentCookie! = $value | | Isset ($currentCookie)) {Setcookie ("StyleSheet", $value, Time () +600000);/* expires in hours*/return $_cook ie["StyleSheet"]; }else{return $_cookie["StyleSheet"]; } if (Isset ($_get[' style ')) {header ("Location:". $_server[' Http_referer ')); Exit }};
The index.php page is as follows:
My Test Page<?php include ("savestylesheet.php"); if (Isset ($_cookie["StyleSheet")) {?>
"/><?php}else{?>
<?php}?> Style Sheet 1
Style Sheet 2
Style Sheet 3
Default Style Sheet
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/1031489.html www.bkjia.com true http://www.bkjia.com/PHPjc/1031489.html techarticle PHP Implementation of the method through the cookie skin, PHP to implement cookie skin This article describes the PHP implementation of the method of skin change through cookies. Share to everyone for your reference. Specific as follows: Savestyles ...