Wisej.Web.Application.Cookies.add(cookie) not working!

Answered
0
0

Hello Love the product, so far.

While working with some cookies I have found that the Wisej.Web.Application.Cookies.add(cookie) doesn’t actually save the cookie properly as a work around I am currently using  Wisej.Web.Application.Cookies.add(cookie.name,cookie.value) which seems to save the cookie, but I am loosing my Expire times so it is just using the basic default expire instead of the one set for the specific cookies. Is there away around this or will I need to wait for a update before this works properly and if i need to wait for the update would it be better to just use the sessions instead of cookies currently?

  • You must to post comments
Best Answer
1
1

Thank you for the sample. I have attached the fixed code, it’s working correctly. These were the issues with the sample code:

  • In Window1_Load the code was always setting textBox1.Text = “no cookie” since there was no else after if (c != null)
  • In button1_Click in new FormsAuthenticationTicket you were using the value as the name and setting the value (UserData) to “” so when reloading the cookie in Window1_Load this linetextBox1.Text = FormsAuthentication.Decrypt(c.Value).UserData; always set the text to “” and then it was overridden again by textBox1.Text = “no cookie”;
  • In button1_Click the cookie was created using Secure=true which works only on ssl (https) connections. Cookies set with secure are not returned by the browser on http connections.

Replace Window1.cs with attached one and it should all work fine.

 

Best,

Luca

Attachment
  • You must to post comments
0
0

Thanks for your quick answer Luca.

Unfortunately I may not of explained the question/concern well so I did what you suggested made a quick test example that you can try out to see what I am talking about. First time through everything works great if you leave the page and come back everything is great if you kill vs debug session and start it over the cookie is no longer present so it isn’t actually saving.

Thanks for your help in advance.

Attachment
  • You must to post comments
0
0

Hi David,

Thank you for trying Wisej. The standard expire times makes the cookie self delete when you close the browser. I tried to add a cookie and set an expire time in 2018 and the cookie persisted correctly. However, when receiving the cookie back from the browser and inspecting the properties you will always see DateTime.MinValue because the browser doesn’t send back the expiration of a cookie. That information is not available in the browser, you get only the name and value.

Was this the issue? If not, can you send a small test?

Best,

Luca

 

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.