I've this:
// connect to MemberHub
function connect() {
// get unique id cookie
var uid = $.cookie('UniqueID', { path: '/' });
member.server.connect(uid).done(function (result) {
if (result.msg == 'success') {
// notify user
$('#log').append($('<li>', { html: 'Connected to MemberHUB' }));
}
});
}
Each time I try to read cookie it creates same cookie instead of read it.
Update: Here is how I assign cookies:
public static HttpCookie Create(string name, string value,
DateTime expires, HttpContextBase httpContext)
{
var cookie = new HttpCookie(name)
{
Value = value,
Expires = expires,
Secure = true,
HttpOnly = false,
Path = "/"
};
httpContext.Response.Cookies.Add(cookie);
return cookie;
}
Any advice will be helpful.
$.cookie
is only read access if no other parameters (but the cookie's name) are supplied to the method [See the source]
If you're interested in reading it, just supply $.cookie('UniqueID')
and remove the second parameter.
As an FYI, path
(and other cookie properties) are only relevant when assigning a value, not retrieving. In other words, you don't need to supply path:'/'
to get cookies that are applied to that path, document.cookie
should natively perform that check.