Results 1 to 5 of 5

Thread: PHP cookie script for IE failing?

  1. #1
    Join Date
    Feb 2007
    Location
    Earth
    Posts
    133
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default PHP cookie script for IE failing?

    PHP Code:
    if(!$_COOKIE['passer'] || $_COOKIE['passer']!='blo'){
    if(!
    $_POST['submit']){
    echo 
    "<form action=ROMDB.php method=post><input class='button' name='pass' type='password'><input class='button' type='submit' name='submit' value='Submit Password'></form>";
    exit;
    }else{
    if(
    $_POST['pass']!='blo'){
    echo 
    "Incorrect pass! <a href='ROMDB.php'>Go back</a>";
    exit;
    }else{
        
    setcookie ("passer"""time() - 3600);
        
    setcookie("passer","blo",time()+60*60*24*30,"/",0); 

    }

    why would this not work in internet explorer?? its not saving the cookie

    first i expire the cookie then remake it...

    it will submit first and you can see the rest of the page, but if you hit refresh or navigate back its like you never inserted a password in the first place...
    http://www.insanecombat.com << bored? check out ma game

  2. #2
    Join Date
    Dec 2008
    Posts
    28
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default

    use $_SESSION['id'];

    =D.

    i believe that is the same thing, just much safer.

  3. #3
    Join Date
    Feb 2007
    Location
    Earth
    Posts
    133
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default

    thanks, after reading a tutorial i added session variables and its working perfect! unfortunatly i dont know how long sessions in php last, they dont mention it... any idea?
    http://www.insanecombat.com << bored? check out ma game

  4. #4
    Join Date
    Dec 2008
    Posts
    28
    Thanks
    3
    Thanked 1 Time in 1 Post

    Default

    I'm not sure how long they last.

    But if you just add

    PHP Code:
    <?php
    session_start
    ();
    ?>
    above everything else on your page, they will keep going.

  5. #5
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    Sessions last until the browser is closed.
    Try this:
    PHP Code:
    <?php
    if (!$_COOKIE['passer'] || $_COOKIE['passer'] != 'blo') {
     if (!
    $_POST['submit']) {
      echo 
    "<form action=ROMDB.php method=post><input class='button' name='pass' type='password'><input class='button' type='submit' name='submit' value='Submit Password'></form>";
      exit;
     } else {
      if (
    $_POST['pass'] != 'blo') {
       echo 
    "Incorrect pass! <a href='ROMDB.php'>Go back</a>";
       exit;
      } else {
        
    setcookie("passer""blo"time() + 60 60 24 30"/"0);
      }
     }
    ?>
    Jeremy | jfein.net

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
  •