Announcement

Collapse
No announcement yet.

cookies

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • cookies

    ok, i have the option for a user to select different styles to view my page in..
    <example>
    http://kidzonfire.org/new/?style=1
    http://kidzonfire.org/new/?style=3
    http://kidzonfire.org/new/?style=5
    </example>

    but... the styles selection page should set a cookie on the users system
    http://kidzonfire.org/new/?page=style

    It does, but ONLY for that current browser..
    ie, you load a new browser and it shows it in the default colors...

    I'll post the php in a reply in a second

  • #2
    Here's the PHP Update code:
    PHP Code:
    if (!isset($mode))
    {
    echo 
    "<span class='newstitle'>Style Selection Form</span>";
    echo 
    "<span class='p'>";
    echo 
    "You are currently using the $style_css style<br>";
    echo 
    "Select the style you want from the drop down box below then click 'Submit'.  If you have trouble seeing small text you should pick the LF version (Large Font)<br><br>";
    if    (!
    $HTTP_COOKIE_VARS['style'])
    {
    echo 
    "<form action='http://www.kidzonfire.org/new/style.php?mode=switch' method='post'>";
    echo 
    "<Select name=style>";
    echo 
    "<option value='1'>Orange</option>";
    echo 
    "<option value='2'>Orange LF</option>";
    echo 
    "<option value='3'>White</option>";
    echo 
    "<option value='4'>White LF</option>";
    echo 
    "<option value='5'>Black</option>";
    echo 
    "<option value='6'>Black LF</option>";
    echo 
    "</select>";
    echo 
    "&nbsp;&nbsp;&nbsp;<input type=submit value='Submit'>";
    echo 
    "</form>";
    }
    else echo 
    "Notice: You must disable a custom style before trying a new one, <a href='http://www.kidzonfire.org/new/style.php?mode=delete_cookie'>Click Here</a> to reset your styles<br><br>";
    echo 
    "</span>";
    }

    if (
    $mode == 'switch')
     {
         
    SetCookie("style","$style");
         require(
    "/usr/local/kidzonfire.org/include/styles.php");
         echo 
    "<html>";
         echo 
    "<head>";
         echo 
    "<title>Style Applied</title>";
         echo 
    "<link rel='stylesheet' type='text/css' href='http://www.kidzonfire.org/new/styles/$style_name/$style_css.css'>";
         echo 
    "</head>";
         echo 
    "<body>";
        echo 
    "<table width='100%' noborder cellpadding='0' cellspacing='0'>";
        echo 
    "<tr>";
        echo 
    "<td rowspan='3' width='0*' height='100%' background='styles/$style_name/main_01.gif'><img src='styles/$style_name/main_01.gif' width='1' height='100%'></td>";
        echo 
    "<td width='0*' height='100%' background='styles/$style_name/main_77.gif'><img src='styles/$style_name/main_02.gif' width='211' height='15' /></td>";
        echo 
    "<td  width='0*' height='0*' background='styles/$style_name/main_77.gif'><img src='styles/$style_name/main_03.gif' width='69' height='15' align='right'></td>";
        echo 
    "<td rowspan='3' width='0*' height='100%' background='styles/$style_name/main_01.gif'><img src='styles/$style_name/main_01.gif' width='1' height='100%'></td>";
        echo 
    "</tr>";
        echo 
    "<tr>";
        echo 
    "<td colspan='2' width='100%'>";
        echo 
    "<span class='newstitle'>Style Applied</span><span class='nav'><br><br>";
        echo 
    "<blockquote>Style has been changed, please <a href='http://www.kidzonfire.org/new/'>Click Here</a> to return to KidzonFire.org<br>";
        echo 
    "To change to another style <a href='http://www.kidzonfire.org/new/?page=style'>Click Here</a>";
        echo 
    "<blockquote></span>";
        echo 
    "</td>";
        echo 
    "</tr>";
        echo 
    "<tr>";
        echo 
    "<td colspan='2' height='0*' width='100%' background='styles/$style_name/main_01.gif'><img src='styles/$style_name/main_01.gif' height='1'></td>";
        echo 
    "</tr>";
        echo 
    "</table>";
        echo 
    "</body></html>";
     }

     if (
    $mode == 'delete_cookie')
     {
         
    SetCookie("style","");
                 require(
    "/usr/local/kidzonfire.org/include/styles.php");
                 echo 
    "<html>";
                 echo 
    "<head>";
                 echo 
    "<title>Style Deleted</title>";
                 echo 
    "<link rel='stylesheet' type='text/css' href='http://www.kidzonfire.org/new/styles/orange/orange.css'>";
                 echo 
    "</head>";
                 echo 
    "<body>";
                echo 
    "<table width='100%' noborder cellpadding='0' cellspacing='0'>";
                echo 
    "<tr>";
                echo 
    "<td rowspan='3' width='0*' height='100%' background='styles/$style_name/main_01.gif'><img src='styles/$style_name/main_01.gif' width='1' height='100%'></td>";
                echo 
    "<td width='0*' height='100%' background='styles/$style_name/main_77.gif'><img src='styles/$style_name/main_02.gif' width='211' height='15' /></td>";
                echo 
    "<td  width='0*' height='0*' background='styles/$style_name/main_77.gif'><img src='styles/$style_name/main_03.gif' width='69' height='15' align='right'></td>";
                echo 
    "<td rowspan='3' width='0*' height='100%' background='styles/$style_name/main_01.gif'><img src='styles/$style_name/main_01.gif' width='1' height='100%'></td>";
                echo 
    "</tr>";
                echo 
    "<tr>";
                echo 
    "<td colspan='2' width='100%'>";
                echo 
    "<span class='newstitle'>Style Removed</span><span class='nav'><br><br>";
                echo 
    "<blockquote>Style has been changed, please <a href='http://www.kidzonfire.org/new/'>Click Here</a> to return to KidzonFire.org<br>";
                echo 
    "To change to another style <a href='http://www.kidzonfire.org/new/?page=style'>Click Here</a>";
                echo 
    "<blockquote></span>";
                echo 
    "</td>";
                echo 
    "</tr>";
                echo 
    "<tr>";
                echo 
    "<td colspan='2' height='0*' width='100%' background='styles/$style_name/main_01.gif'><img src='styles/$style_name/main_01.gif' height='1'></td>";
                echo 
    "</tr>";
                echo 
    "</table>";
                echo 
    "</body></html>";
     }

    ?> 
    Here's the PHP Style Definition:
    PHP Code:
     if (!isset($style))
         {
         
    //Page with Orange Background
             
    $style_name "orange";
             
    $style_css "orange";
         }
     if (
    $style == "1")
         {
        
    //Page with Orange Background
             
    $style_name "orange";
             
    $style_css "orange";
         }
     if (
    $style == "2")
         {
        
    //Page with Orange Background + Large Fonts
             
    $style_name "orange";
             
    $style_css "orange-large";
         }
     if (
    $style == "3")
         {
         
    //Page with White Background
             
    $style_name "white";
             
    $style_css "white";
         }
     if (
    $style == "4")
         {
         
    //Page with White Background + Large Fonts
             
    $style_name "white";
             
    $style_css "white-large";
         }
     if (
    $style == "5")
         {
         
    //Page with Black Background
             
    $style_name "black";
             
    $style_css "black";
         }
     if (
    $style == "6")
         {     
         
    //Page with Black Background + Large Fonts
             
    $style_name "black";
             
    $style_css "black-large";
         } 

    Comment


    • #3
      would it work if i set $style to $HTTP_COOKIE_VARS["style"]???

      Comment


      • #4
        Browsers set cookies independantly of each other.
        IE saves cookies in C:\Windows\Temperary Internet Files\ as well as C:\Windows\Cookies\.
        Netscape saves them somewhere else. I don't know where, I don't use netscape.

        Comment


        • #5
          No, i load a new IE browser and it sets the style to 1.. not what the cookie was

          Comment


          • #6
            Oh, I'm sorry. I thought you ment you set a cookie with IE, and Netscape couldn't read it.

            Add an expire time. If that doesn't work, try adding a domain arguement.

            More info about setCookie() here.

            Comment


            • #7
              well, i just taught myself sessions, so i'm fine now

              Comment


              • #8
                Sessions will solve part of the problem... but it wont remember the next time they visit.

                If that doesn't matter, then who cares. Bravo!

                Comment


                • #9
                  where are you passing the time argument to setcookie or are you doing that elsewhere?
                  Cons

                  Comment


                  • #10
                    id actually pass the whole setcookie again with domain, time, position etc etc
                    Cons

                    Comment

                    widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                    Working...
                    X