Shinori Posted October 24, 2017 Share Posted October 24, 2017 function createCookie(name,value,days) { var expires = ""; if (days) { var date = new Date(); date.setTime(date.getTime() + (days*24*60*60*1000)); expires = "; expires=" + date.toUTCString(); } document.cookie = name + "=" + escape(value) + expires + "; path=/"; } function user_login() { var uname = document.getElementById('input-loginname-homepage').value; var psw = document.getElementById('input-loginpassword-homepage').value; var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { if(this.responseText != "ERR") { var array = this.responseText.split("|"); createCookie("cookie_user_uname",array[0],365); createCookie("cookie_user_psw",array[1],365); } } } xmlhttp.open('POST', 'ajax/login.php?uname=' + uname + '&psw=' + psw, true); xmlhttp.send(); } Other browser working fine. Chrome just seems to not create the cookies. Chrome Version 61.0.3163.100 And no I am not trying to access the page locally (file://...) It`s an up an running website on the web. (https://...) Returned stuff via AJAX from login.php ist like "randomusername|$2y$12$bH/yQet2GxEae00PUUKmIedtkxaHZCiR5csyAzz3/3J..." Thank you! Link to comment Share on other sites More sharing options...
justsomeguy Posted October 24, 2017 Share Posted October 24, 2017 Print that cookie string to the console to see what you're telling it to set. PHP has a built-in way to track the logged in user using sessions though, that's probably better than trying to manage it yourself. Link to comment Share on other sites More sharing options...
Shinori Posted October 25, 2017 Author Share Posted October 25, 2017 (edited) NVM. Anti-Virus-Software blocking cookies in chrome for my website... Thanks for the help! Edited October 25, 2017 by Shinori Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now