my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes Accessing php session variable in JavaScript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Accessing php session variable in JavaScript" Watch "Accessing php session variable in JavaScript" New topic
Author

Accessing php session variable in JavaScript

Udaya Wijenayake
Ranch Hand

Joined: May 15, 2009
Posts: 30
I want to access a php session variable within a JavaScript function? How would i do it? Please give an example code.


SCJP 1.5
Senthil Manoharan
Greenhorn

Joined: Mar 01, 2010
Posts: 28
Hi Udaya,

try this code
var sessionVariable=<?php echo "$_SESSION['<variablename>']";?>;


Thanks and Regards
Senthil Kumar M
Senthil Manoharan
Greenhorn

Joined: Mar 01, 2010
Posts: 28
Hope the above will work
 
Don't get me started about those stupid light bulbs.
 
subject: Accessing php session variable in JavaScript
 
Similar Threads
input/output stream
javascript to php conversion
HTML-Formfield
How to Retrieve a Servlet Session variable in PHP
Content-Length header