permaculture playing cards*
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 OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP 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
 
wood burning stoves
 
subject: Accessing php session variable in JavaScript