Cookie Secure

Discussion in 'PHP' started by Pudge1, Mar 4, 2010.

  1. #1
    People are using a FireFox editing program to change the value of cookies and forge things on my site. How do I make it so they cannot do this?
     
    Pudge1, Mar 4, 2010 IP
  2. hireme

    hireme Member

    Messages:
    58
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    45
    #2
    use session?
     
    hireme, Mar 4, 2010 IP
  3. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #3
    Can sessions be forged?
     
    Pudge1, Mar 4, 2010 IP
  4. hireme

    hireme Member

    Messages:
    58
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    45
    #4
    yes they can be forged but not if you save session id's in a database, then check if the session is a valid one.
     
    hireme, Mar 4, 2010 IP
  5. Pudge1

    Pudge1 Well-Known Member

    Messages:
    912
    Likes Received:
    6
    Best Answers:
    1
    Trophy Points:
    140
    Digital Goods:
    1
    #5
    I am having some problems creating the sessions. I used this
    
    session_start();
    $_SESSION['score'] = $score
    
    Code (markup):
    And then on another page I used

    
    if(isset($_SESSION['score']))
     {
      echo $_SESSION['score'];
     }
    else
     {
      echo 'Error';
    }
    
    Code (markup):
    It just displays Error for some reason. What am I doing wrong? Do you have to use session_start(); on the same page you are attempting to display $_SESSION['score']?
     
    Pudge1, Mar 5, 2010 IP
  6. halfdata

    halfdata Active Member

    Messages:
    98
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    53
    #6
    Include session_start(); at the beginning of another page.
     
    halfdata, Mar 5, 2010 IP
  7. SpamHat

    SpamHat Peon

    Messages:
    27
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Encrypt your cookie values & verify the cookie date.

    Job done.
     
    SpamHat, Mar 6, 2010 IP
  8. JEET

    JEET Notable Member

    Messages:
    3,832
    Likes Received:
    502
    Best Answers:
    19
    Trophy Points:
    265
    #8
    That is what I was going to suggest. You can use mcrypt to handle the encryption.
    There are free php classes which allow you to easily use mcrypt.
    Thanks :)
     
    JEET, Mar 6, 2010 IP
  9. n3r0x

    n3r0x Well-Known Member

    Messages:
    257
    Likes Received:
    4
    Best Answers:
    1
    Trophy Points:
    120
    #9
    Stop storing information in cookies.. just store a key that is linked to the information in a session table.. = impossible to alter values.
     
    n3r0x, Mar 7, 2010 IP