none
How to persist cookie on auto redirect URLs ? RRS feed

  • Question

  • I am using .NET 3.5 Winforms Web Browser control where I am trying to implement SSO for my app. I am getting authenticated successful and receiving all the cookies from the SSO service. When the browser automatically tries to redirect the URL to the app URL, the cookies are dropped or is getting set to empty. Can anyone please let me know how can I preserve the cookie on all the auto re-directs that is happening at the time of login ?

    Also, If I try to navigate directly "https://hostserv.com/secureauth799/" page, things are working fine. Somehow "https://webui.na.hostserv.com/" navigation is not working due to cookie drop.

    Below is the entire code flow.

    ***Navigating***
    URL: https://webui.na.hostserv.com/
    Cookie: NULL
    ***DocumentCompleted***
    URL: https://webui.na.hostserv.com/login
    Cookie: SessionID=fs213bfqro4x4ctkjsucwmksis; SecAuthLogin=PUBLIC; PreAuth=8DA8A878328B62D195473A5574B6C5059AF67D2BF9092FE3D7F3BED52CC1173F891C222D4854CA7986DCCEBA240BB28047B8827119C4EB22892F12E139BC3E723892F1C34807F95EA97959FBAC747AB0406861FC25EADF6D0ED13BC164F639876EAB8D5B; SSOToken=D87D4B5812284C94A7B7A195CE8396949673465C04FEBAA70A0965BF2EF7EBA2553FF5AA90F05F47FEE8068987B7704167754D520AB53D7D7D55223D0CD2DA59482F07648486FCF4E872932EF32FE92098722C3F87414E10444EFE91746F6E743369A049D68338E08CABED41C7F07DDA5B83B5C9BFB83F4A26464BEC9DD25A00F96DED69C52A3929BD13BFD879D5A192F8CBED45317E4949EEA91288DA214777A50DF121849F9CEA77DB504F92F939F89C914893; csrfToken=99m2AA09TRwy59vq-jLTY98bg8_QC8reSRqzQDYWmmOE; XSRF-TOKEN=99m2AA09TRwy59vq-jLTY98bg8_QC8reSRqzQDYWmmOE
    ***Navigating***
    URL: https://hostserv.com/secureauth799/
    Cookie: SessionID=fs213bfqro4x4ctkjsucwmksis; SecAuthLogin=PUBLIC; PreAuth=8DA8A878328B62D195473A5574B6C5059AF67D2BF9092FE3D7F3BED52CC1173F891C222D4854CA7986DCCEBA240BB28047B8827119C4EB22892F12E139BC3E723892F1C34807F95EA97959FBAC747AB0406861FC25EADF6D0ED13BC164F639876EAB8D5B; SSOToken=D87D4B5812284C94A7B7A195CE8396949673465C04FEBAA70A0965BF2EF7EBA2553FF5AA90F05F47FEE8068987B7704167754D520AB53D7D7D55223D0CD2DA59482F07648486FCF4E872932EF32FE92098722C3F87414E10444EFE91746F6E743369A049D68338E08CABED41C7F07DDA5B83B5C9BFB83F4A26464BEC9DD25A00F96DED69C52A3929BD13BFD879D5A192F8CBED45317E4949EEA91288DA214777A50DF1219238373933939382ixnhdsdy27383922; csrfToken=99m2Axjcid93Rwy59vq-jLTY98bg8_QC8reSRqzQDYWmmOE; XSRF-TOKEN=99m2AA09T827mdxx-jLTY98bg8_QC8reSRqzQDYWmmOE
    ***DocumentCompleted***
    URL: https://hostserv.com/secureauth799/
    Cookie: 
    Thursday, November 14, 2019 6:09 PM

All replies

  • Hi Sameer S Panicker,

    If you want to pass cookie value from webbrowser control to webclient , this document maybe helpful for you.

    [Passing Cookie Value from webbrowser Control to webclient in an Authenticated Environment]

    Best Regards,

    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, November 15, 2019 7:29 AM
  • I don’t need to pass it to a web client. When I navigate to a url, I will be passing some cookies and the url provides an redirect url. I want the same cookies to be forwarded to all the consecutive redirects happening.
    Friday, November 15, 2019 1:51 PM
  • Hi Sameer S Panicker,

    Here is a similar issue you can refer to.

    [Cookies lost during multiple redirects]

    You can try the parveenoodles's workround.

    Best Regards,

    Daniel Zhang


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, November 18, 2019 9:53 AM