This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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
 
Consider Paul's rocket mass heater.
 
subject: Accessing php session variable in JavaScript
 
Similar Threads
input/output stream
Content-Length header
javascript to php conversion
HTML-Formfield
How to Retrieve a Servlet Session variable in PHP