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

87
Vistas
Why different php session value in Chrome and FireFox?

set a session value to 10 by ajax. In Chrome it will set back to ZERO. Why?? my.php

<?php
session_start();
$_SESSION["temp"] = 0; ?>


<div id="t">$_SESSION["temp"] = <?=$_SESSION["temp"]?> <br></div>
<br><input type="button" value="Plus 5" onclick="javascript:plusn(5);">
<script>
    function plusn(n) {
          $.ajax({
              url: 'myajax.php?n='+n,
              type: 'get',
              async: false,
              success:function(result){
                  $("#t").append(result)
              }
          });
    }
    
    $(document).ready(function() {
        plusn(10); //initial add 10
    })
</script>

myajax.php

<?php
session_start();
$_SESSION["temp"] += $_GET["n"];
exit('$_SESSION["temp"] = '.$_SESSION["temp"].'<br>');
?>

place here: https://cmbody.com/my.php Please use different browsers to check it. Chrome, Edge and Android cell phones get the wrong result; Firefox and iPhone get the correct results. P.S. same condition using COOKIE

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

Here's the culprit:

<link rel="shortcut icon" href="#" />

The browser tries to load the favicon from the same URL, as instructed. For that, it performs an additional request to the main PHP script. The differences happen because Firefox uses the cached page and Chrome-based browsers fetch a fresh copy:

Firefox

Chrome

over 4 years ago · Santiago Trujillo Denunciar

0

It works correctly when I send it with a 1000 millisecond delay but this is not a correct solution I will continue to investigate.

setTimeout(()=>{
        plusn(10);
    },1000)
over 4 years ago · Santiago Trujillo Denunciar
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