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 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效
  • ¥15 再不同版本的系统上,TCP传输速度不一致
  • ¥15 高德地图点聚合中Marker的位置无法实时更新
  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题