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

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

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序