Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How access session in JavaScript?

I created session in CakePHP like this:

$User = array('userid'=>232, 'access'=>1)
$this->Session->write('User',$User);

Now I want to check userid in session using JavaScript / jQuery

Is there any direct method to access this session in JavaScript.

Thanks

like image 214
Awan Avatar asked Nov 30 '22 06:11

Awan


1 Answers

Is there any direct method access this session in JavaScript directly.

No. Session data is stored on the server.

In order to access it, you need to expose it on a URI via PHP, and then make an HTTP request to that URI (possibly using Ajax).

like image 174
Quentin Avatar answered Dec 04 '22 09:12

Quentin