SESSION or COOKIE

Discussion in 'PHP' started by gr8webseller, Dec 29, 2009.

  1. #1
    I am developing a site where peoples can register for account, but i get confused weather to use session or cookie,,,,

    and also i like to know, with using session i can implement "remember me" option,,, ??

    what are the adv. & disadv. of session & cookies,,,

    give advice what to use weather session or cookies or both,,,
     
    gr8webseller, Dec 29, 2009 IP
  2. tvshock

    tvshock Peon

    Messages:
    102
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    the different betwen session and cookies is session store the information on you server , cookies store the information on the user computer. to make a registration i like to use session because some user have set the browser to don't accept cookies.
     
    tvshock, Dec 29, 2009 IP
  3. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #3
    A lot of times sessions will use cookies to keep track of the session id anyways. When a session can't use cookies, it will end up passing the SID along with GET variables on the URL.
     
    joebert, Dec 29, 2009 IP
  4. kingsoflegend

    kingsoflegend Well-Known Member

    Messages:
    202
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    108
    #4
    Session variables have a very short life span; they last until the end of the visit. When the user closes their browser, all the info stored by session variables is lost, so you can't have a remember me option that uses session. Also session variables tend to expire even before the end of the visit, so if you have a log in system that uses them, users will occasionally be logged out while browsing through your site.

    Implement both and use cookies as the default choice. If they are disabled on the user's computer, switch to session instead.
     
    kingsoflegend, Dec 29, 2009 IP
  5. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #5
    use both... basically set the login system to work on session but also create cookies system so that if sessions arent there but cookies are then users can login directly
     
    Bohra, Dec 29, 2009 IP
  6. gr8webseller

    gr8webseller Peon

    Messages:
    1,097
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks for reply
     
    gr8webseller, Dec 29, 2009 IP