我想允许用户通过单击按钮更改我的网站主题颜色。目前我将css指针保存到url上。但是当跳转到其他页面时,css指针从新页面的url中消失了,所以主题颜色恢复为默认值。如何让每个页面都记住当前选中的css?我可以将 css 指针保存到 php 会话吗?怎么做?
代码:
<html>
<head>
<link rel="stylesheet" href="css/theme-<?php if ($css=="blue" || $css == "") echo "blue"; else echo $css; ?>.css" type="text/css" media="screen" title="csstheme" />
<?php require_once("session.php"); ?>
</head>
<body>
<a href="<?php print $_SERVER['PHP_SELF'];?>?<?php print $querystring;?>&css=blue" ><img src="http://plekz.com/images/layouts/blue.jpg" /></a>
<a href="<?php print $_SERVER['PHP_SELF'];?>?<?php print $querystring;?>&css=green" ><img src="http://plekz.com/images/layouts/green.jpg" /></a>
<a href="<?php print $_SERVER['PHP_SELF'];?>?<?php print $querystring;?>&css=pink" ><img src="http://plekz.com/images/layouts/pink.jpg" /></a>
<a href="<?php print $_SERVER['PHP_SELF'];?>?<?php print $querystring;?>&css=white" ><img src="http://plekz.com/images/layouts/white.jpg" /></a>
<a href="<?php print $_SERVER['PHP_SELF'];?>?<?php print $querystring;?>&css=red" ><img src="http://plekz.com/images/layouts/red.jpg" /></a>
</body>
</html>