douwen3965 2014-02-13 16:10 采纳率: 0%
浏览 60

在PHP AWS中管理会话

I have a website which is hosted on AWS, I cant trust this session array $_SESSION[] as sometime select * from table_name where id=$_SESSION[id] doesn't work as expected. I am looking for some session management trick, is it ok If I use Database or Dyanmo DB. If there is a scalable application which has lot of user on it.what would be the prefered way for doing it?

  • 写回答

1条回答 默认 最新

  • douwei1904 2014-02-13 22:22
    关注

    You have 3 basic options for storing sessions in php: file based, memcached, and database backed.

    If you use file based session, then you need to use sticky sessions, so subsequent requests from the same user get routed back to the same instance. This may not work if you are using autoscaling - if an instance is stopped, then that user will lose his session.

    You can use memcached, where there is a single memcached instance that stores session. This is probably the easiest option. No state is saved on the instances, and you do not need to use sticky session. As long as you don't exceed the available memory for memcached, you should be OK.

    The third option is to use a database backed session. This should have the same effect as using memcached sessions, but does allow more complex behavior - for instance, you can replicate your databases across datacenters and theoretically that allows you to have an application that scales across multiple regions.

    评论

报告相同问题?

悬赏问题

  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示