douwu7563 2014-03-25 10:44
浏览 24
已采纳

我的PHP会话登录世界

I've encountered a weird problem with PHP Sessions that I'm not sure how to fix. I know that there's a problem with my code, but Googling the matter and searching for answers her yielded no results...possibly because I have no idea how to make keywords for this!

Basically I'm making a login script to learn PHP better, and so I encountered sessions. I got them working somewhat, but trouble is that when I successfully log in, the session that's created logs the world into my account no matter from where or with what browser is used.

I'm pretty sure I'm missing a step, so if anyone could help me figure that out, that'd be great!

Presently I have this on top of every page dealing with sessions:

session_id("tenaarFeiriSess"); // Define the session name.
@session_start();

error_reporting(E_ALL);

The actual login applies the session like this, where $usr = username:

$_SESSION['loggedin'] = $usr;

What am I missing?

  • 写回答

1条回答 默认 最新

  • doulin4844 2014-03-25 10:47
    关注

    The problem is that you give everyone the exact same session with session_id(). PHP automatically sets a session id for everyone so this is really unnecessary. Once you remove this, it should work.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法