douyiken0968 2010-04-14 15:11
浏览 27
已采纳

如何为访客创建个人资料?

I'm making a site, and will be allowing guests to vote/comment. How should I go about storing the user info?

I wouldn't like the info to be cleared if someone deletes the cookie (SO handles guest users via cookies I guess). If someone clears cookies and changes the ip at once, then only should the guest user info should be lost.

Should I use sessions in php for this?

  • 写回答

3条回答 默认 最新

  • duangang3832 2010-04-14 15:40
    关注

    To persist user information reliably you should store it on your server with some kind of user id based on the cookie etc. Php sessions only support sessions, so are helpful to maintain identity within a session. Once a user closes his browser and starts it up again the PHP session may be gone. Similarly cookies may be gone as well.

    Relying on IPv4 addresses however is not going to get you very far. Even disregarding people on dynamic IP addresses (every time they access the internet they have a different ip) there are plenty of people sharing IP's through NAT. You don't want to share a user for an entire office of people do you?

    So in short, you could use PHP sessions in addition to your normal cookie (in case the user disables cookies) but you cannot get his identity back if he is anonymous and he decides to delete his cookies. Remember that under water PHP sessions work by means of cookies (and fall back request parameters only when cookies are disabled)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection
  • ¥15 nginx代理报502的错误
  • ¥100 当AWR1843发送完设置的固定帧后,如何使其再发送第一次的帧
  • ¥15 图示五个参数的模型校正是用什么方法做出来的。如何建立其他模型
  • ¥100 描述一下元器件的基本功能,pcba板的基本原理
  • ¥15 STM32无法向设备写入固件
  • ¥15 使用ESP8266连接阿里云出现问题
  • ¥15 BP神经网络控制倒立摆
  • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果