Asked by:
Cookie value lost when redirect to a new page. (iOS only)

Question
-
User944339287 posted
Hi guys, my web application having an issue.
Cookies value will be lost when redirecting to a new page (dashboard.aspx)
This problem ONLY occurred when I log-in using apple phone (iOS). Working fine in android phone and desktop.
I have confirmed my safari is Cookies Enabled. Any idea?
Login.aspxIf IsNothing(Request.Cookies("CustomerInCakes")) = False Then Response.Redirect("/customer-portal/dashboard.aspx", False) Else me.lbl_result.Text = "Cookies is NOT existing" End If
Dashboard.aspx
If IsNothing(Request.Cookies("CustomerInCakes")) = True Then Response.Write("Cookies is NOT existing") Else Response.Write("Cookies is existing") End If Dim colCookies As ArrayList = New ArrayList Dim i As Integer = 0 Do While (i < Request.Cookies.Count) colCookies.Add(Request.Cookies(i)) i = (i + 1) Loop Me.GridView.DataSource = colCookies Me.GridView.DataBind()
Form.browser
<browsers> <browser refID="Default"> <controlAdapters> <adapter controlType="System.Web.UI.HtmlControls.HtmlForm" adapterType="FormRewriterControlAdapter" /> </controlAdapters> <capabilities> <capability name="cookies" value="true" /> </capabilities> </browser> </browsers>
Friday, January 11, 2019 8:00 AM
All replies
-
User753101303 posted
Hi,
I've seen this asked quite few times in this forum and never remember to test about this. My understanding is that when sending both cookies and doing a redirect some browsers (ie Safari ?) are doing only the redirect. Most often the response is to redirect on the client side instead.
Edit: old but for example: https://discussions.apple.com/thread/7770177
(you have a single redirect or in close succession, this is not cross domain, you may want just to try a basic test to make sure what happens).
Friday, January 11, 2019 9:09 AM -
User944339287 posted
Hi,
<g class="gr_ gr_67 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-ins replaceWithoutSep" id="67" data-gr-id="67">Sorry</g> <g class="gr_ gr_68 gr-alert gr_tiny gr_spell gr_inline_cards gr_run_anim ContextualSpelling multiReplace" id="68" data-gr-id="68">i</g> don't see any solution from your link. I <g class="gr_ gr_108 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" id="108" data-gr-id="108">have</g> make sure my safari is enabled cookies. And yes it's NOT cross domain redirection.
Based on my testing.. my cookies is existing before redirecting to page B. Any idea?Friday, January 11, 2019 9:45 AM -
User753101303 posted
It was just to point it seems a Safari behavior.
The usual suggestion is to render the page so that cookies are taken into account and include javascript code such as document.location.href="somewhere"; so that cookies are set and redirection is done.
I would test maybe with Chrome or Edge on the same iOS version (wonder if this is Safari or some underlying behavior in the http stack). This is which version of Safari/iOS ?
Friday, January 11, 2019 10:21 AM -
User944339287 posted
Hi,
I have tried using javascript to do redirection instead of response.redirect but still not working. (cookies is lost)
ScriptManager.RegisterStartupScript(Me.Page, Page.GetType, "text", "Redirect()", True)
my iOS version is 12.1.2
I have tried with (Firefox version 14.0) but still failed.
Friday, January 11, 2019 11:03 AM -
User753101303 posted
You are 100% sure you removed the server side redirection ?
Else I would try maybe one page that set cookies and on which I click manually to go another page. If cookies are not sent yet, it would really point at a general cookie issue (try maybe to clear the browser cache to see what happens) rather than just this "set cookie and redirect in the same response" issue.
Or maybe you mistakenly use http with "secure cookies" (they are sent back only if using https).
Friday, January 11, 2019 11:37 AM -
User475983607 posted
There is no indication that you have set a cookie in the first place. Can you share the code that sets the cookie and explain the design? Try setting a break point on the code that creates the cookie and verify it works.
Friday, January 11, 2019 3:49 PM