I have a php that sets:
setrawcookie('psd_susenka', rawurlencode("cookie_value"), time() + (86400 * 365));
I even tried the long version with paths, domains, and switches (http only and secure, both with false values)
then, after reloading the page I have jquery:
$(document).ready(function(){
alert(document.cookies);
})
If the only cookie set is "psd_susenka" then I get alert with "Undefined". If I set another cookies with $.cookie("test", something, { expires: 365 });
then the alert writes only the cookies set via jquery
So what is wrong with the php code? Or maybe something wrong with the jquery alert? I got <script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
loaded and the cookie is manualy checked in chrome so it exists.
You probably have a typo.
Try document.cookie
instead document.cookies
.
Documentation: https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie
P.S. document.cookie
is part of WebAPI (see: https://developer.mozilla.org/en-US/docs/Web/API). This is not part of jQuery and not part of JavaScript. JavaScript (also jQuery, because it works only with JavaScript) is able to work with WebAPI.