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条)

报告相同问题?

悬赏问题

  • ¥15 关于无人驾驶的航向角
  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退