1

I just get:

8:21 Uncaught TypeError: Cannot read property 'set' of undefined 

for:

@Scripts.Render("~/bundles/jquery") @Scripts.Render("~/bundles/jqueryval") <script src="~/Scripts/jquery.cookie.js"></script> <script> $.cookies.set('TEST', "VALUEEEE", { path: '/' }); // <-- errs here </script> 

I'm in MVC5, tried this directly on a page, in layout, in partial.... no go anywhere... simply get this error no matter what. File is in place from NuGet package and referenced as you see here... Confirmed jQuery loaded, and jquery cookie file loaded...

Screenshot

Cannot get this to work... any ideas?

4
  • is it Cookies (with capital C) ? Commented May 18, 2016 at 20:44
  • "var config = $.cookie = function..." don't think so github.com/carhartl/jquery-cookie Commented May 18, 2016 at 20:45
  • 1
    never mind, docs (github.com/carhartl/jquery-cookie) indicate you need to use something like $.cookie('name', 'value'); - there is no .set(..) Commented May 18, 2016 at 20:46
  • bingo... make it a post and I'll mark as answer. All the examples I saw has .cookies.set I shoulda read the main doc more carefully Commented May 18, 2016 at 20:48

2 Answers 2

2

It should be like below

var cook = $.cookie('TEST', "VALUEEEE", { path: '/' }); 
Sign up to request clarification or add additional context in comments.

Comments

1

The docs for the library indicate usage to be like this:

$.cookie('name', 'value'); 

There is no .set(...) function

1 Comment

There is a side-effect due to the backwards compatibility attempt where in version 1.5.1 where you can use the .set method in the $.cookie namespace, but that is not documented and therefore it should not be used in any circumstance.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.