Mike’s Experiments - PHP: Style Changer

This PHP script checks to see if the user allows cookies. If so, a function is provided to change to an alternate CSS. If the user doesn’t accept cookies, this script offers a message, but normally it shouldn’t, and should instead simply remove the optional function from view.
Get the PHP, source. Go to back to the Mike’s Experiments index.


PHP: Style Changer Data, Output, and Interface

The is the raw data output by the script. It is these variables that, if properly employed, will alter the CSS import statement to grab the user’s preferred style sheet. Assuming, of course, cookies are allowed. Check it out:


Combining these variables in a CSS import statement will generate the following:

<style type="text/css" media="screen" title="Default Style"> 
    @import "styles/default.css";
</style>

Note: If you accepted cookies from this site, you would see a link here allowing you to select a different page style. You could also post a message here suggesting the user accept cookies so the style changer becomes available, but the whole idea behind this portion of the script is to remove the non-functional option altogether.


gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.