https://www.youtube.com/watch?v=5XddDvUEU7o
How to add cookies in MikroTik Hotspot page
this code will be make cookies in web browser
if the phone have random mac or if you need save cookies only in client device
before head tage in login page
Code: Select all
<script type="text/javascript">
window.addEventListener('load', function() {
// Function to check if a cookie exists
function checkCookie(cookieName) {
var cookies = document.cookie.split("; ");
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i].split("=");
if (cookie[0] === cookieName) {
return cookie[1];
}
}
return null;
}
// Get the values from the cookies
var username = checkCookie("usernameX");
var password = checkCookie("passwordX");
// Set textbox values if cookies are valid
if (username !== null && password !== null) {
document.login.username.value = username;
document.login.password.value = password;
}
});
function setCookie(cookieName, cookieValue, expirationDays) {
var d = new Date();
d.setTime(d.getTime() + (expirationDays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
document.cookie = cookieName + "=" + cookieValue + ";" + expires + ";path=/";
}
</script>
Code: Select all
setCookie("usernameX", document.login.username.value, 2);
setCookie("passwordX", document.login.password.value, 2);