SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Serialize not working??

    i am trying to set a cookie after serializing the data in it. but it doesnot seem to work.
    i thought might be i am passwing wrong values so i just used three lines to see if its working . iused following lines
    PHP Code:
    $cookie ="username||password||option";
    $cookie serialize($cookie);
    echo 
    $cookie
    and the output is
    s:26:"username||password||option";
    is the answer correct?.
    because the reason i am using this function is to kinda encrypt data of cookie

  2. #2
    Non-Member Icheb's Avatar
    Join Date
    Mar 2003
    Location
    Germany
    Posts
    1,474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    serialize() is for an example used to store the contents of an array as a string representation, so that you can easily store it somewhere. See www.php.net/serialize .
    You need other functions if you want to encrypt the data.

  3. #3
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    so, as i suspected i was wrong. any ideas how i should store my cookie securely.
    and thanx for the answer Icheb

  4. #4
    SitePoint Wizard Dangermouse's Avatar
    Join Date
    Oct 2003
    Posts
    1,024
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    store the username and md5 of password in cookie, then when they return lookup the password from the username in the cookie, md5 it, and check it against the password in the cookie

  5. #5
    Umm. PHP Guru....Naaaah jaswinder_rana's Avatar
    Join Date
    Jul 2004
    Location
    canada
    Posts
    3,193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dangermouse
    store the username and md5 of password in cookie, then when they return lookup the password from the username in the cookie, md5 it, and check it against the password in the cookie
    i tried it and its working. the only problem is when i store it in cookie my password is md5 but my username is stored in clear text. should i worry about it & change it or that's the way to do it??

  6. #6
    SitePoint Evangelist
    Join Date
    May 2004
    Location
    Germany
    Posts
    550
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if you want to be able to encrypt and decrypt you might want to look at mcrypt


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
  •