dougan7657 2015-04-07 06:22
浏览 83

通过javascript从会话中提取用户名

I am trying to extract user logged-in name from client side i.e javascript. I am able to get cookie that is set at client side which stores current user session id. But how to get user name from that PHPSESSION ID ? And i dont want to use any API.
As session is set at server side I am unable to get that information.

Following is what i got, session id by document.cookie
Please help me out.

Thanks in advance

  • 写回答

1条回答 默认 最新

  • dongyupan4850 2015-04-07 07:16
    关注

    You might have set username in php global variable- $_SESSION['username']

    You can extract this from javascript using the following line.

    <script>
     var username="<?php echo $_SESSION['username']; ?>";
    </script>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?