fun getCookieValue(name: String): String? {
val currentCookies = document.cookie.split(";")
for (cookiePair in currentCookies) {
val cookieKeyValue = cookiePair.split("=")
if (cookieKeyValue.first().trim() == name.trim()) {
return cookieKeyValue[1].trim()
}
}
return null
}
Two questions:
1. Is there any better way to do it?
2. How to delete a cookie key value?