doushenyu2537 2010-07-23 14:42
浏览 60
已采纳

什么是session_id,session_regenerate_id和session_name用于?

ok im a newbie on sessions lets imagine that we have a little login site,

heres a logic

  1. login
  2. if password right = use $_SESSION[isaloginuser] = 1
  3. check session to see menus with if $_SESSION[isaloginuser] = 1
  4. show the menus
  5. the user want to logoff
  6. unset session
  7. destroy session system

what it use

session_register
session_destroy
session_unset
session_start

where does the session_id & the session_regenerate or session_name goes in ? at php site it says

session_id() is used to get or set the session id for the current session.

i still just dont get it, why do we need them anyway ? in real environment what does it do ?

  • 写回答

5条回答 默认 最新

  • dongzhuxun5136 2010-07-23 14:49
    关注

    No, you don’t need to use them. In general all you need is

    • session_start to start the session handling, and
    • session_destroy to destroy the stored session data (this does not modify $_SESSION), and
    • session_unset to reset the $_SESSION variable (but you can also do $_SESSION = array()).

    session_id and session_name are to get and set the current session ID and session ID name (default is PHPSESSID). session_regenerate_id can be used to regenerate/change the session ID of the current session. This might be useful if, for example, you want to refresh the session ID every 10 minutes or after changing the state of authenticity of a user associated with a session.

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

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!