# android


10/30/2023, 4:03 PM
hey all, getting some very strange behaviour with webviews and base64 encoding. basically, i am able to set cookies as long as they havent just been base64 encoded. see below
Copy code
val validCookieString = "MTExMDkxNTM0MaDoxNjEzMDg5MzYzNw==" // encoded string copy pasted from logs, works ok
        val invalidCookieString = "${bip}:${cap}".encodeToBase64() // doesnt work
        val bpCaCookie =
            "ai" to invalidCookieString

        debug { bpCaCookie.second }
        with(CookieManager.getInstance()) {
            removeAllCookies {
                setCookie(url, "${bpCaCookie.first}=${bpCaCookie.second}")  // inside webview, the cookie isnt set if using invalidCookieString
and the encoding logic
Copy code
private fun String.encodeToBase64() =
        Base64.encodeToString(this.toByteArray(), Base64.DEFAULT)
not kotlin but kotlin colored 1
to top it all off this all only started happening on friday, on all previous versions of the app
i see the not kotlin react, i shouldve expressed this better though as i think the issue has to do with the specific strings themselves and why they may not be exactly the same even if they appear to be