I using https://github.com/carhartl/jquery-cookie/blob/master/jquery.cookie.js for the cookie function.
My problem is that the cookie seems like deleted after browser restart?
Here are the summary on the code,
if ( $.cookie("latlng") ) {
myLatlng = $.cookie('latlng').split(',');
myLatlng = new google.maps.LatLng(myLatlng[0], myLatlng[1]);
} else {
$.cookie("latlng", "3.139, 101.686", { path: '/' });
myLatlng = new google.maps.LatLng(3.139, 101.686);
}
...
google.maps.event.addListener(marker1, 'dragend', function() {
var temp = marker1.getPosition().lat() + ',' + marker1.getPosition().lng()
$.cookie("latlng", temp, { path: '/' });
});
add an expires value. to expire in 7 days: