Customize design using GET variable
-
Hello everyone,
I‘m struggling with a noob issue here again:
I‘m trying to make my site look specific, when someone with a certain GET variable comes in. Currently, the code in my functions.php looks like this:
First I store the GET variable in a Cookie and a Session (native session plugin is installed):
function set_cookie_session(){ if ( isset($_GET['abc']) ){ global $wp_session; if( ! session_id() ) { session_start(); } $_SESSION["abc"] = $_GET['abc']; setcookie("abc", $_COOKIE["abc"], time() + 60 * 60 * 24 * 30, "/", "my-site.com", true, true ); } } add_action( 'init', 'set_cookie_session', 9 );
and then I try to add the specific style to the header:
function customize_abc() { if( isset($_COOKIE["abc"] || isset($_SESSION["awc"]) ) { echo "<style>…..</style>"; } } add_action( 'wp_head', 'costomize_abc', 20 );
I can see the cookie in my browser. But this 2nd piece of code neither detects the cookie nor the session variable. When I try to print them they are both empty. I even moved the cookie setting into the header.php but same issue.
Where is my mistake and how can I do this better?
Thanks all!
The page I need help with: [log in to see the link]
- The topic ‘Customize design using GET variable’ is closed to new replies.