dongwen7423 2011-09-20 19:44
浏览 53
已采纳

在子域中的域中的Cookie中

I have two application in my work Asp.Net MVC and PHP.

PHP is my domain.

MVC is my subdomain.

php when creating the cookie looks like this -

u%3Dxxxxxx%40xxxxxx.com%26e%3D20%2F9%2F2011+17%3A05%3A04%26c%3D4c059a53d2134867fdb64b44714f2463

and

mvc when creating the cookie looks like this -

u=xxxx@xxxxx.com&e=20/9/2011 20:04:12&c=8CDC334D509AED502402AAF3537DD226

the domain in cookie = .xxx.com

But when i try to read the cookie in Mvc the cookie dont work.

cookie["u"]
cookie["e"]
cookie["c"]

What might be going wrong?

Thank you

Sorry my english

  • 写回答

1条回答 默认 最新

  • douliudong8108 2011-09-21 06:07
    关注

    You should ensure that when the cookie is created (on the PHP site), the Set-Cookie header looks like this:

    Set-Cookie: u=some_value; domain=example.com
    

    Now you will be able to access this cookie from any subdomain on example.com. Inside the ASP.NET MVC application you can access it like this:

    public ActionResult Index()
    {
        var cookie = Request.Cookies["u"];
        ...
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用