duanjie6912 2010-07-29 01:07
浏览 66
已采纳

当我进行ajax php查询时,Cookie是否可以访问?

I know this has been asked before but I needed some clarification and confirmation. I've been told when creating cookies, to use httponly to prevent XSS.

So my clarification is if I use httponly, will my php scripts accessed via ajax request still be able to determine my active php session (default: phpssessid) and retrieve my $_SESSION variables?

The thing is I didn't design with httponly option and I'm concerned if adding that option will in any way affect the design of the script.

Thanks!

  • 写回答

1条回答 默认 最新

  • dsfsd43523 2010-07-29 03:50
    关注

    I'm not sure I get the question, but here's a stab: you'd need to setup the session the same way on the script you're calling from ajax as you did on your main page. For example, I have a single file I "include" in my main page, and anything I call from that page using ajax.

    so, the top of my index.php has

    <?php include "db.php"; ?><!DOCTYPE...
    

    same thing on the top of my ajax_helper.php file

    <?php include "db.php"; ?>
    

    the db.php file contains the mysql startup commands, session_start, and anything else that would be common to all pages on the site. That way, the session works anywhere.

    I hope that makes sense and answers your question

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

报告相同问题?

悬赏问题

  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备