Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

180
Vistas
A new Cookie is added instead of replacing existing one

I just finished localizing my web application using spring boot configuration as a base.

@Bean
public LocaleResolver localeResolver() {
    return new CookieLocaleResolver();
}

Due to a requirement one is supposed to be able to change locale/language of the website by pressing a button. Said function is implemented with a little bit of JS and a cookie.

<script>
    function updateCookie(lang) {
        let name = "org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE"
        document.cookie = name+"="+lang
        location.reload()
    }
</script>

<a onclick="updateCookie('de')" class="flag-icon flag-icon-de mr-2"></a>

The idea is to update said cookie on click of a button and use it throughout the whole application. This works fine until I am trying to call a specific endpoint in my application.

In order to debug my application I use:

window.onload = function () {
        alert(document.cookie)
}

Now to my problem:

When User-Testing the application this is the alert-feedback:

org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE=de

Switching to other pages, refreshing, changing language etc. properly resets the cookie with a different value.

When calling a specific endpoint though, I get the following alert:

org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE=de;
org.springframework.web.servlet.i18n.CookieLocaleResolver.LOCALE=fr

Instead of resetting/changing the existing cookie, a new one is added with the value 'de;'. A seemingly random semicolon is added.

This doesn't happen with endpoints using similar logic and almost identical implementation. There is no further logic outside the little bit of JS code I've posted and I'm not touching the cookie in the backend.

Unfortunately I'm out of ideas. Any tips/help would be appreciated.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda