technique to add and remove cookies after output

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jon Slaughter

    technique to add and remove cookies after output

    I have developed a technique to add and remove cookies after output...
    wondering if there is something else like this out there?

    Jon


  • Mike P2

    #2
    Re: technique to add and remove cookies after output

    On May 18, 3:29 pm, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.comwrot e:
    I have developed a technique to add and remove cookies after output...
    wondering if there is something else like this out there?
    >
    Jon
    Are you sending some JavaScript to do the work?

    I think there shouldn't be a good reason to need to do this anyway,
    unless you don't have interface code separated from business logic.

    -Mike PII

    Comment

    • Jon Slaughter

      #3
      Re: technique to add and remove cookies after output


      "Mike P2" <sumguyovrthar@ gmail.comwrote in message
      news:1179518074 .937833.39770@p 77g2000hsh.goog legroups.com...
      On May 18, 3:29 pm, "Jon Slaughter" <Jon_Slaugh...@ Hotmail.comwrot e:
      >I have developed a technique to add and remove cookies after output...
      >wondering if there is something else like this out there?
      >>
      >Jon
      >
      Are you sending some JavaScript to do the work?
      >
      I think there shouldn't be a good reason to need to do this anyway,
      unless you don't have interface code separated from business logic.
      >
      -Mike PII
      >
      I'll explain it in another post later. It essentially lets you inline cookie
      setters in the html code using php. It doesn't use javascript and
      essentially is based on caching and callback's. It not be worth the trouble
      as I'm stillt rying to iron out a few bugs but if I can clean it up some
      then it might be worth it.

      Jon


      Comment

      • Jon Slaughter

        #4
        Re: technique to add and remove cookies after output

        BTW, heres what I'm doing now,

        Probably doesn't make much sense but if you look at the bottom of the page
        you'll see how I add cookies into the form. After a user has clicked on a
        button, the cookies there will be added. I just have to add the ability for
        dynamic data of the cookies which I'll do tomorrow.

        Essentially what this creates is a self contained paged. The line

        if (isset($_SESSIO N['CALLBACKURL']) & !empty($_SESSIO N['CALLBACKURL']))

        determines if its suppose to set the cookies or not and if so then does it
        and then moves onto the next page. The code I have is working fine now but
        probably is pretty buggy. Once I implement the dynamic code for the cookies
        I'll post the code and see if anyone is interested in it and provide some
        working examples. Right now the only page is the one below and it sets and
        removes cookies. There are no other pages it links too.


        you can goto to see it in action



        The only pages on the site are Weblogin.php and Index.php. Weblogin only
        holds the class.


        <?php

        session_start() ;
        error_reporting (E_ALL); ini_set('displa y_errors','1');
        ini_set('displa y_startup_error s','1'); ini_set('log_er rors','1');
        ini_set('displa y_startup_error s','1');

        @require_once($ _SERVER['DOCUMENT_ROOT'].'/Scripts/WebLogin.php');
        $login = new WebLogin();


        if (isset($_SESSIO N['CALLBACKURL']) & !empty($_SESSIO N['CALLBACKURL']))
        {
        $url = $_SESSION['CALLBACKURL'];
        $login->SetCookies() ;


        session_destroy ();
        unset($_SESSION );
        unset($_COOKIE) ;


        $url = '/Index.php';

        echo '<meta content="0; URL='.$url.'" http-equiv="Refresh" />';
        exit();
        }

        $login->DecodeCookies( );






        if (empty($_COOKIE ) | !isset($_COOKIE ))
        {
        echo "<br />No Cookies<br />\n";
        }
        else
        {
        echo "<br />Displaying Cookies<br />\n";
        foreach($_COOKI E as $key =$val)
        {
        echo "&nbsp;&nbsp;&n bsp;&nbsp;&nbsp ;&nbsp;&nbsp;". $key." =>
        ".htmlentities( serialize($val) )."<br />\n";
        }
        }


        $login->StopDB();
        ?>

        <html>
        <body>
        <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
        <label>Cookie Name: </label><input name="CookieNam e" value="Jo" type="text"
        /><br />
        <label>Cookie Data: </label><input name="CookieDat a" value="Blow"
        type="text" /><br />
        <input name="FormActio n" type="submit" value="Add Cookie">
        </form>
        <?php $login->AddCookieP('Ad d Cookie', '/ShowCookies.php/', 'CookieName',
        'CookieData', array('location ' ='/')); ?>

        <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
        <label>Cookie Name: </label><input name="CookieNam e" value="Jo" type="text"
        /><br />
        <input name="FormActio n" type="submit" value="Delete Cookie">
        </form>
        <?php $login->DeleteCookieP( 'Delete Cookie', '/ShowCookies.php/',
        'CookieName'); ?>

        </body>
        </html>



        Comment

        • Jon Slaughter

          #5
          Re: technique to add and remove cookies after output


          BTW, if you check your cookie files then you might notice something
          different. I suppose redirecting to the same page isn't all that big of a
          deal but also the cookies are encoded, encrypted, and hash validated which
          is one reason for the login class(along with user login database stuff).


          Comment

          Working...