1

I have created a cookie in javascript...

(document).ready(function () {
    $.cookie("test", "Hello Michael");
    alert($.cookie("test"));
});

The alert displays the cookie content as expected. And I am trying to read it back in vb.net code behind...

Dim cookie As HttpCookie
cookie = HttpContext.Current.Request.Cookies.Get("test")

If IsNothing(cookie) Then
  txtCookie.Text = "Cookie not found"
Else
  txtCookie.Text = cookie.Value
End If

I always get 'Cookie not found".

I am clearly missing something... please advise!

1
  • (document), $ missing..a typo?
    – Shaunak D
    Apr 29, 2015 at 14:57

1 Answer 1

0

You need to add the path value to the cookie,

$.cookie("test", "Hello Michael", { path : "/" });

And, Request.Cookies("test") would work. Also, (document), $ is missing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.