V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
wuxiaolin
V2EX  ›  PHP

通过 ajax 去登录如何设置 session

  •  
  •   wuxiaolin · Sep 22, 2016 · 5870 views
    This topic created in 3510 days ago, the information mentioned may be changed or developed.

    使用场景是这样的:
    a.b.com 是前端页面,纯静态的页面,数据都是通过 ajax 调用的。
    i.b.com 是调用的接口域名。
    a.b.com 通过 ajax 的方式去登录帐号,同时设置 session 。登录成功后,请求 i.b.com 时, session 是空的。有什么方法解决这个问题没有?
    ps:session_set_cookie_params(3600 , '/', '.b.com'); 这种方式已经使用,并不能读取到。

    3 replies    2016-09-22 14:30:12 +08:00
    laoona
        1
    laoona  
       Sep 22, 2016
    跨域,默认的 ajax 请求,是不带任何请求凭证的,设置 xhr 的 withCredentials =true
    tinyproxy
        2
    tinyproxy  
       Sep 22, 2016   ❤️ 1
    wuxiaolin
        3
    wuxiaolin  
    OP
       Sep 22, 2016
    @tinyproxy 在这里的答案里面找到了解决方案,感谢
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2368 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 01:41 · PVG 09:41 · LAX 18:41 · JFK 21:41
    ♥ Do have faith in what you're doing.