Jump to content

Creating Cookies in Chrome not working


Shinori
 Share

Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...