2016-09-22 21:45

类'SessionHandler'找不到PHP 5.3.3


I am having big issues implementing SessionHandler class on my app.

Unfortunately, I am stuck on 5.3.3 version and I can't upgrade to a newer version, because our server has to use that version.

Is there any alternative solution to implement SessionHandler class?

By looking into documentation, SessionHandler requires min 5.4 version.


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • douwaif22244 douwaif22244 5年前

    Right, the SessionHandler interface was not implemented in PHP until PHP 5.4. Unfortunately, PHP 5.3 reached its end of life over 2 years ago. If you're using anything prior to PHP 5.6.0, right now, you're using a version of PHP that will no longer receive updates or support. So you will not be able to take advantage of such new features that newer and current versions of PHP have to offer.

    The SessionHandler interface is the only interface exposed to userland PHP that allows you to hook directly int PHP's session handler. Prior to that you had to write your own custom session handling code as a C extension to register it as one of the session_save_handlers that PHP would use to handle sessions.

    Since you have no direct interface you're forced to do this type of thing ad-hoc in your unsupported version of PHP. i.e. by reading directly from your session storage, deserializing it manually, writing your own wrappers, and then serializing and writing back out to your storage location.

    This means you would not be able to take advantage of any of PHP's built-in features to rely on doing so, such as session_start(), session_write_close(), or the $_SESSION super global variable. You will have to wrap all of these things in your own PHP code and will be forced to call on your own PHP abstraction throughout your application code to deal with the session calls for you.

    点赞 评论 复制链接分享