Pass $_SESSION in load() jquery

Asked

Viewed 64 times

-1

I wonder if it is possible to pass one $_SESSION for load() jquery.

I have a page, where I call for another load, but I need to get the value of $_SESSION on the second page, but it’s not working, hence my question is this, is it possible to pass $_SESSION for load(), for for $.post() worked out.

PAGE 1:

<?php
    session_start();
    $_SESSION['id'] = 1;
?>

$(document).ready(function(){
    $("#retorno").load("pagina1.php");
})

PAGE 2:

<?php
    session_start();

?>
<div class="teste">
    <?php echo $_SESSION['id']; ?>
</div>

I did something similar in my script and it didn’t work, all the files are in UTF-8 sem BOM.

Possible is, I used the plugin EditThisCookie, and I was able to verify the error, on a given page he created the session cookie with a name different, hence when calling on the other side could not pick up the session, because the cookie was under another name.

  • abcd is always using PHP, the global $_SESSION is always present while logged in.

  • In fact, on a given page he created a name for the SESSION, hence when he called the session he did not recognize, because he created a new cookie...

1 answer

0


If the pages are in the same domain put load it also works and I did a test site here and this ok.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.