Jump to content
Sign in to follow this  
Shinori

Creating Cookies in Chrome not working

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!

 

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...