File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Accessing php session variable in JavaScript
 
Similar Threads
input/output stream
Content-Length header
HTML-Formfield
javascript to php conversion
How to Retrieve a Servlet Session variable in PHP