PHP implementation of the method through the cookie skin, PHP implementation of cookie Skin _php tutorial

Source: Internet
Author: User

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 ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.