This article mainly introduces how php achieves skin replacement by using cookies and how to use cookies to store user-selected information for skin replacement. It has some reference value. For more information, see
This article mainly introduces how php achieves skin replacement by using cookies and how to use cookies to store user-selected information for skin replacement. It has some reference value. For more information, see
This example describes how to use cookies to skin in php. Share it with you for your reference. The details are as follows:
The saveStyleSheet. php page is as follows:
<? Php function styleSheet ($ currentCookie) {// Get Current Style Sheet $ currentCookie =$ _ COOKIE ["StyleSheet"]; // Get New cookie file nameswitch ($ _ 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 cookie to the defaultif (! Isset ($ _ GET ['style']) {$ value = 'style.css ';} // If the new value doesn't equal the old value allow cookie changeif (isset ($ value) | $ currentCookie! = $ Value | isset ($ currentCookie) {setcookie ("StyleSheet", $ value, time () + 600000 ); /* expires in 10,000 hours */return $ _ COOKIE ["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 will help you with php programming.
,