0

I have created a session in jquery using following code

$.session.set("name","xyz");

Now when i try to access the session 'name' in php i cant

$name=$_SESSION['name'];
  • 1
    I've never heard of `$.session`, is that a plugin? Where does it write its data? Unless it's making AJAX calls to server-side pages you've added which interact with the session, it's not going to have anything to do with your server-side session. – David Aug 25 '18 at 16:07

2 Answers2

0

it is not possible because they are different context.

PHP doc http://php.net/manual/fr/reserved.variables.session.php

jQuery doc https://plugins.jquery.com/tag/session/

What you are probably looking for (the answer) Read session value with Javascript

Ggg
  • 64
  • 8
0

$.session.set stores the data in the browser something like a local storage which is accessible across multiple pages from the same site during a browser session. This data stored and accessible on the browser.

But a PHP session variable is stored and accessible in the server. So you cannot access a value stored in jquery session from a PHP session. Hope it clears your confusion

Rinsad Ahmed
  • 1,877
  • 1
  • 10
  • 28