Problem Reading Jquery Cookie In Yii

I am using the jquery cookie plugin that is included in Yii.

In my javascript file, I am creating a new cookie this way:

$.cookie('test',12, { expires: 7, path: '/'});

When I reload the page, this cookie exists in


but I cannot access it through


Am I doing something wrong? Thank you in advance.

I think it can be caused by enableCookieValidation.

That’s right, I had cookie validation enabled. Once I removed it, the cookie appeared in yii variables!

So, either I will go on using $_COOKIE or I will disable validation. If you can tell me some way to create yii-validated cookies through jquery cookie, let me know.

Thank you very much!

I think you have to send an ajax request to set a “yii-validated” cookie, because only Yii knows the private key used to generate cookie hash. I guess you don’t want to keep it in javascript code :)