$_SESSION help

Discussion in 'PHP' started by acdc236, Nov 20, 2008.

  1. #1
    I need to know if I created millions upon millions of $_SESSIONs do you think this would overload a server? this site is getting millions of hits and sessions will be more secure for us. thanks for your help
     
    acdc236, Nov 20, 2008 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    Unless you have unlimited bandwidth, or you were setting hundreds or thousands of session variables, I think you would see performance degradation in several other areas before sessions could ever cause a problem.
     
    jestep, Nov 20, 2008 IP
  3. acdc236

    acdc236 Peon

    Messages:
    110
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    ya each session will have 5 variables max, most will have 2. so you guys think it will be okay?
     
    acdc236, Nov 20, 2008 IP
  4. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #4
    One thing you can so is look at your session_save_path in php.ini. Watch the available space in that location if you are worried. Session data is stored there, so you should get a good idea on whether it is going to cause a problem. Also keep in mind that session data is destroyed after a certain amount of time.
     
    jestep, Nov 20, 2008 IP
  5. acdc236

    acdc236 Peon

    Messages:
    110
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    ya I guess it makes sense, PHP probably wouldnt have even implemented sessions if they werent able to be used on a mass scale. thanks for your help
     
    acdc236, Nov 20, 2008 IP
  6. eric90

    eric90 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    5 variables per session shouldn't be a real problem. although what you can do is set the session to timeout faster, and just make known to users that transactions expire after x amount of time or something.
     
    eric90, Nov 21, 2008 IP
  7. AdultProfiles

    AdultProfiles Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    There's no problem
     
    AdultProfiles, Nov 21, 2008 IP
  8. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #8
    PHP saves sessions in a single folder, keep in mind that the server would need to search through one file for every active session for every request. That means if you have 1 million active sessions, the server will have to search through 1 million files to fnd the session when the user requests the page, then do that again when the browser comes back for CSS, JS, images, etc, every one of them.

    I don't think you should even think about it unless you setup a RAM based session_save_handler such as memcached.
     
    joebert, Nov 22, 2008 IP
  9. share_boy

    share_boy Active Member

    Messages:
    71
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #9
    Php language has designed to handle million session realtime.
    Maybe Your hosting performance could be the main problem.
     
    share_boy, Nov 22, 2008 IP