Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing php session variable in JavaScript

 
Udaya Wijenayake
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to access a php session variable within a JavaScript function? How would i do it? Please give an example code.

 
Senthil Manoharan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Udaya,

try this code
var sessionVariable=<?php echo "$_SESSION['<variablename>']";?>;
 
Senthil Manoharan
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hope the above will work
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic