Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 3 of 3

This is a discussion on Cookie Woes! in the Shared & Semi-Dedicated forum
Here are the codes for 3 files I am using to set a cookie. Please scroll down after the code for my problem. Login_form.html <?php ...

  1. #1
    JPC Senior Member
    Join Date
    Oct 2003
    Location
    Alaska
    Posts
    82

    Cookie Woes!

    Here are the codes for 3 files I am using to set a cookie. Please scroll down after the code for my problem.

    Login_form.html
    <?php
    include 'header.html';
    ?>

    <form action="testing5.php" method="post" name="" id="">
    <table width="50%" border="0" align="center" cellpadding="4" cellspacing="0">
    <tr>
    <td width="22%">Username</td>
    <td width="78%"><input name="username" type="text" id="username"></td>
    </tr>
    <tr>
    <td>Password</td>
    <td><input name="password" type="password" id="password"></td>
    </tr>
    <tr>
    <td>Set Cookie.</td>
    <td><input type="checkbox" name="remember"></td>
    <tr>
    <td>&nbsp;</td>
    <td><input type="submit" name="Submit" value="Submit"></td>
    </tr>
    </table>
    </form>

    <?php
    include 'footer.html';
    ?>


    testing5.php
    <?php
    $cookie_remember = $_POST['remember'];
    $username = $_POST['username'];
    $password = $_POST['password'];

    if($cookie_remember == "on") {
    include 'testing2.php';
    echo "It's on.";
    exit();
    } else {
    echo "It's off.";
    }
    ?>

    testing2.php
    <?php
    $cookieuser = md5($username);
    $cookiepass = md5($password);
    setcookie("booger", "$cookieuser", time()+3600*24*100, "", ".kornmonkie.com", 0);
    setcookie("booger2", "$cookiepass", time()+3600*24*100, "", ".kornmonkie.com", 0);
    ?>
    This setup is just me trying to figure out how to pass cookies, I will not be using the username and password in the final cookie. Login_form.html sends the value of 'username' 'password' and 'remember' to testing5.php. Testing5.php calls testing2.php, where the code for setting the variables to MD5 and setting the cookie are. With this setup, the cookie placement works, but when I add the contents of testing2.php to this area after the IF statement, replacing the include, it does not work. Here is what I would like it to look like.

    testing5.php
    <?php
    $cookie_remember = $_POST['remember'];
    $username = $_POST['username'];
    $password = $_POST['password'];

    if($cookie_remember == "on") {
    $cookieuser = md5($username);
    $cookiepass = md5($password);
    setcookie("booger", "$cookieuser", time()+3600*24*100, "", ".kornmonkie.com", 0);
    setcookie("booger2", "$cookiepass", time()+3600*24*100, "", ".kornmonkie.com", 0);
    echo "It's on.";
    exit();
    } else {
    echo "It's off.";
    }
    ?>
    I have been getting the echo of "It's on," but nothing is being written into the cookie. I know cookies are sent in the headers, so maybe I am screwing up there? Any help would be appreciated.
    "Play the best song in the world, or I'll eat your soul."
    I am a D fan in the arctic wastes of Alaska.

  2. #2
    JPC Senior Member
    Join Date
    Oct 2003
    Location
    Alaska
    Posts
    82
    Nevermind...
    I got it working.

    Isn't it funny when you work on something for hours and it fails, then you go back the next day, and on the first try you get it?
    "Play the best song in the world, or I'll eat your soul."
    I am a D fan in the arctic wastes of Alaska.

  3. #3
    Old Hillbilly Connie's Avatar
    Join Date
    Sep 2001
    Location
    Hills of Missouri
    Posts
    2,648
    Quote Originally Posted by kornmonkie
    Nevermind...
    I got it working.

    Isn't it funny when you work on something for hours and it fails, then you go back the next day, and on the first try you get it?
    Sometimes you can't see the forest for the trees or vice versa. At least that is my experience. Glad you got it worked out.

    Forum Moderators - Jag Staff

    Spam Whackers Blog - Dedicated to fighting Spam and providing General SEO Tips
    Organize your Kitchen or purchase Kitchen Accessories at Condells
    Ihelpyou Forum - Dedicated to "Best Practices" SEO

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •