Search Unity

Unable to read "Set-Cookie" header in WebGL

Discussion in 'Web' started by IanSwift, Oct 2, 2016.

  1. IanSwift

    IanSwift

    Joined:
    Oct 2, 2016
    Posts:
    2
    Hi Unity,

    After I noticed UnityWebRequest was not capturing from the Set-Cookie header and placing it in subsequent Cookie headers, I wrote some code to do that for me. It works fine in the editor (and standalone) but as soon as I use WebGL, the webRequest.GetResponseHeader("Set-Cookie") always returns null. I'm wondering if there's an intended way to get and set cookies that I'm missing, or if something peculiar is going on here? I did notice this thread as reference:

    https://forum.unity3d.com/threads/unitywebrequest-setrequestheader-cant-set-cookie-header.361818/

    Thanks!

    EDIT:

    I just found out that GetResponseHeaders on my response is returning null. Yet there are clearly response headers in the network profiling. Something is up with WebGL. Does anyone know why I can't access any of my headers?

    EDIT 2:

    Success! OK So if anyone is reading this thread, make sure you have CORS enabled for your resource. Specifically the Header "Access-Control-Expose-Headers"

    https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Access-Control-Expose-Headers
     
    Last edited: Oct 3, 2016
  2. rolandlivingstone

    rolandlivingstone

    Joined:
    Jun 24, 2015
    Posts:
    4
    i've meet the same situation. "EDIT 2" was really saved my ass:)
     
  3. AliAnkara

    AliAnkara

    Joined:
    Dec 17, 2017
    Posts:
    7
    [QUOTE = "rolandlivingstone, mesaj: 3175648, üye: 869547"] aynı durumu karşıladım. "EDIT 2" gerçekten kıçımı kurtardı :)[/ QUOTE]

    Çerez üzerinde örnek kod gerekir.
    Çok sıkıldım.