User Management - Store Sessions In DB Or Server?

Discussion in 'PHP' started by jnm, Apr 2, 2007.

?

Which is better for user management?

  1. Storing sessions on the Server.

    5 vote(s)
    83.3%
  2. Storing sessions in MySQL (or other DB).

    1 vote(s)
    16.7%
  1. #1
    Well, this is more to stir a debate than anything...or at least good reference point for people to choose correctly.

    Each person has their own beliefs in performance. Each use can be based on project.

    So basically, which is better:

    1. Storing user sessions in MySql (or other DB)...
    2. Letting the server handle it...


    I wish I could contribute!

    -j
     
    jnm, Apr 2, 2007 IP
  2. Rogem

    Rogem Peon

    Messages:
    171
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Woah, 100% of people say 'Storing sessions on the Server.'. This seems a somewhat single sided vote :p

    Righty, let me cover this:
    1. Storing user sessions in MySQL is a good way of doing things, though is slow and not great for big sites. A better idea would be to have checks on the username, password then comparing a sessionid with whats set in the DB and $_Session.
    2. Comparing with what is posted and set by the server does work, but it's not 100% secure.

    I would recommend a mixture of both.
     
    Rogem, Apr 3, 2007 IP
  3. CodyRo

    CodyRo Peon

    Messages:
    365
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    MySQL, storing it on the server is moronic (unless you plan on using it for non-sensitive data)
     
    CodyRo, Apr 3, 2007 IP
  4. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #4
    Not enough info to pick a side here.
    What needs to be known most importantly are:
    1. Are we on a shared or dedicated server?
    2. What sort of data is being stored?
     
    phper, Apr 3, 2007 IP
  5. srobona

    srobona Active Member

    Messages:
    577
    Likes Received:
    57
    Best Answers:
    0
    Trophy Points:
    88
    #5

    I agree with phper. More specific information should have been provided which would help the members go for the right choise.
     
    srobona, Apr 4, 2007 IP
  6. PHP5-Hosting

    PHP5-Hosting Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Depends on your use and with your server setup. Maybe you have your site running on cluster of servers and hosting your DB on a different set of servers, then you'd probably think of caching your not so sensitive data on your web server.
    You may store ID's or frequently accessed data (not so confidential ones) in server sessions too.
     
    PHP5-Hosting, Apr 4, 2007 IP