Retrieving cookies with javascript XMLHTTPReq
Date : March 29 2020, 07:55 AM
it helps some times You will be able to get your own site's cookies from document.cookie. In the AJAX callback, use a library to parse the value and read the cookie you're looking for. Of course, if the server sets the cookie HttpOnly (which it should be doing), it won't be available in document.cookie.
|
Setting and Retrieving Cookies using HttpComponents
Tag : java , By : Brandon
Date : March 29 2020, 07:55 AM
it fixes the issue just found the follwoing example which demonstrates the use of cookies in an login example: HttpComponents Example with CookiesMaybe you can modify this in a way what the server responds with the content of the cookie sent, so you can eval if the cookie really was sent to the server. (You send cookie with "foo", "bar" or some randomize values and the server will respond with "bar", "foo" or something like that)
|
javascript cookies, setting multiple cookies
Date : March 29 2020, 07:55 AM
help you fix your problem You need to change from assignment operator (=) to concatenation and assignment compound operator (+=). It would also be a good idea to overwrite the cookie key if it exists. So I'd recommend turning the cookie values into an object, modifying them and then serialising back to a cookie string.
|
Setting Javascript cookies and retrieving them
Date : March 29 2020, 07:55 AM
like below fixes the issue I have changed only 2 lines in your javascript code. I have replaced setting and getting cookie data with localStorage methods setItem() and getItem(). Regarding, how long localStorage keeps data stored, you can better checkout @Pointy's answer here. In short, it's not clear when this data will be cleared (usually it stays long enough in the browser ), but you can clear or update that data any time you want using localStorage.setItem() and localStorage.clearItem() methods. function drag_start(event) {
var style = window.getComputedStyle(event.target, null);
event.dataTransfer.setData("text/plain",
(parseInt(style.getPropertyValue("left"),10) - event.clientX) + ',' + (parseInt(style.getPropertyValue("top"),10) - event.clientY));
}
function drag_over(event) {
event.preventDefault();
return false;
}
function drop(event) {
var offset = event.dataTransfer.getData("text/plain").split(',');
var dm = document.getElementById('dragme');
dm.style.left = (event.clientX + parseInt(offset[0],10)) + 'px';
dm.style.top = (event.clientY + parseInt(offset[1],10)) + 'px';
var pos = {left: dm.style.left, top: dm.style.top};
console.log( pos );
localStorage.setItem("div_position", JSON.stringify(pos));
event.preventDefault();
return false;
}
var dm = document.getElementById('dragme');
try {
var pos = JSON.parse(localStorage.getItem("div_position"));
dm.style.left = pos.left ? pos.left : '0px';
dm.style.top = pos.top ? pos.top : '0px';
} catch (e) {
// Some error handling
}
dm.addEventListener('dragstart',drag_start,false);
document.body.addEventListener('dragover',drag_over,false);
document.body.addEventListener('drop',drop,false);
/*
function drop(event) {
var offset = event.dataTransfer.getData("text/plain").split(',');
var dm = document.getElementById('dragme');
dm.style.left = (event.clientX + parseInt(offset[0],10)) + 'px';
dm.style.top = (event.clientY + parseInt(offset[1],10)) + 'px';
var pos = {left: dm.style.left, top: dm.style.top};
var str = JSON.stringify(pos);
var dat = <?php echo $_GET[date];?>;
document.cookie = dat+"="+str;
event.preventDefault();
return false;
}
var dm = document.getElementById('dragme');
try {
var pos = JSON.parse(dat);
dm.style.left = pos.left ? pos.left : '0px';
dm.style.top = pos.top ? pos.top : '0px';
} catch (e) {
// Some error handling
}
*/
|
Setting and retrieving cookies in c# code behind
Tag : chash , By : Robin Buitenhuis
Date : March 29 2020, 07:55 AM
|