Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access session variable using jQuery

I need to render an HTML element in rails, depending upon whether a session variable is set or not. Is it possible to do something like this?

like image 337
rookieRailer Avatar asked Aug 10 '11 04:08

rookieRailer


2 Answers

Session is server side, I am not a rails developer, but in asp.net mvc I made an ajax call that gets the Session value and returns it back to client. Just an idea.

like image 52
Gabe Avatar answered Sep 24 '22 19:09

Gabe


You cannot access any server side variable from client side. You can basically render the session variable value in a javascript variable and use it on the client side in jquery.

like image 38
ShankarSangoli Avatar answered Sep 26 '22 19:09

ShankarSangoli