1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

Setting "document.cookie"

Discussão em 'Angular' iniciado por sikar, Maio 15, 2025.

  1. sikar

    sikar Guest

    Trying to set cookie below ways and facing issues:

    Option1:

    document.cookie = name + "=" + value + "; expires=" + date.toUTCString() + "; path=/";


    This sets value only till name=value when i recall document.cookie.

    Option 2:

    document.cookie = "${name}=value";
    document.cookie = "expires=${date.toUTCString()}";
    document.cookie = "path=/";


    This works fine and i am able to read all the values from cookie based on ";" split.

    Why this odd behaviour? And in sonarqube report it says assigning document.cookie like the one in option 2 is wrong and its a bug.

    Continue reading...

Compartilhe esta Página