Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. Cookies

Cookies

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
phpmysqlcryptographytoolshelp
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SRJ92
    wrote on last edited by
    #1

    hello, i have been having a few issues with my cookies in php ..... First things first is this script below won't work at all... what am i doing wrong ?

    if (isset($_COOKIE["user"]) && ($_COOKIE["pass"]))
    {
    $user=$_COOKIE['user'];
    $pass=$_COOKIE['pass'];
    }else{
    $user=mysql_real_escape_string($_POST['username']);
    $pass=mysql_real_escape_string(hash('sha512', $_POST['password']));
    $remember = (isset($_POST['remember']));
    }

    However, if i take out all the bits in bold, it works perfectly .... The next thing is i tried a number of times to get my cookies to go back to the previous directory using things like "../" at the end but this doesn't seem to work ... what do i need to do to this script ..... Note: this file is 1 sub folder away from the root...

    if($remember == 1)
    {
    $expire=time()+60*60*24*30;
    setcookie ("user", "test", $expire);
    setcookie ("pass", $pass, $expire);
    }

    Thanks for all your help, steve

    L 1 Reply Last reply
    0
    • S SRJ92

      hello, i have been having a few issues with my cookies in php ..... First things first is this script below won't work at all... what am i doing wrong ?

      if (isset($_COOKIE["user"]) && ($_COOKIE["pass"]))
      {
      $user=$_COOKIE['user'];
      $pass=$_COOKIE['pass'];
      }else{
      $user=mysql_real_escape_string($_POST['username']);
      $pass=mysql_real_escape_string(hash('sha512', $_POST['password']));
      $remember = (isset($_POST['remember']));
      }

      However, if i take out all the bits in bold, it works perfectly .... The next thing is i tried a number of times to get my cookies to go back to the previous directory using things like "../" at the end but this doesn't seem to work ... what do i need to do to this script ..... Note: this file is 1 sub folder away from the root...

      if($remember == 1)
      {
      $expire=time()+60*60*24*30;
      setcookie ("user", "test", $expire);
      setcookie ("pass", $pass, $expire);
      }

      Thanks for all your help, steve

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      I'll try and answer a small part: I think you are missing a second isset in the very first line. :)

      Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups