PHP sessions in a load balancing cluster - how?

后端 未结 10 1965
粉色の甜心
粉色の甜心 2020-11-29 17:44

OK, so I\'ve got this totally rare an unique scenario of a load balanced PHP website. The bummer is - it didn\'t used to be load balanced. Now we\'re starting to get issues.

10条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-29 18:25

    When we had this situation we implemented some code that lives in a common header.

    Essentially for each page we check if we know the session Id. If we dont we check if we're in the situation whehich you describe, by checking if we have stored sesion data in the DB.Otherwise we just start a new session.

    Obviously this requires all relevant data to be copied to the DB, but if you encapsulate your session data in a seperate class then it works OK.

提交回复
热议问题