doumiang2297 2015-01-20 20:40
浏览 64

Laravel 4.2在哪里将用户ID存储在会话数据中?

I'm trying to wrap my head around how Laravel handles session data without digging too deeply into the code, due to time contraints.

It appears that the session ID ('laravel_session', by default) which is stored in a cookie is encrypted, because it is a different, much longer value than I get if I print the value of Session::getId()

So I'm assuming that Laravel is encrypting this value before dropping the cookie, and then decrypting the value to do the session data look-up every time session data is required.

So I guess my first question is:

1. Why is the session ID obfuscated like this? I'm presuming that it is for security purposes?

Secondly, I see no 'user_id' (or similarly worded) key in the actual session data once it has been pulled from disk. In fact, the only thing I see aside from the CSRF _token value is some entry like 'login_42e5d2c566bd0811218f0cf078b76bfd' = 1.

2. What is this data responsible for?

3. Can someone please give me a brief overview of how Laravel associates the session data with a specific user ID?

  • 写回答

1条回答 默认 最新

  • dongxie3701 2015-01-21 09:01
    关注

    Why are you digging into the session to get the user ID? You can have sessions without logging in - so user ID doesnt always mean something.

    If you want the currently logged in user - then you should be using Auth::user()->id

    评论

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP