Creating custom PHP Session handler?

后端 未结 4 1119
梦如初夏
梦如初夏 2020-12-24 02:38

Right now I\'m stuck between using PHP\'s native session management, or creating my own (MySQL-based) session system, and I have a few questions regarding both.

4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-24 03:33

    They are both great methods, there are some downsides to using MySQL which would be traffic levels in some cases could actually crash a server if done incorrectly or the load is just too high!

    I recommend personally given that standard sessions are already handled properly to just use them and encrypted the data you do not want the hackers to see.

    cookies are not safe to use without proper precaution. Unless you need "Remember me" then stick with sessions! :)

    EDIT

    Do not use MD5, it's poor encryption and decryptable... I recommend salting the data and encrypting it all together.

    $salt = 'dsasda90742308408324708324832';
    $password = sha1(sha1(md5('username').md5($salt));
    

    This encryption will not be decrypted anytime soon, I would considered it impossible as of now.

提交回复
热议问题