Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Retrieve a Servlet Session variable in PHP

 
Srikant Mantha
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a validation servlet that sets a variable named "username" using setAttribute() in a Session. This servlet redirects the page to a html file, which is in frames. The 1st section of the frame is a php file. I want to retrieve this variable in my PHP code. The regular way to access the php session variable is like this
echo "UserName=". $_SESSION['username'];.
This result is returning null.
How do I solve this problem ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your only real options are to change the servlet so it writes the value out somewhere or not use PHP.
[ December 16, 2008: Message edited by: Paul Sturrock ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the amount of data is small and not sensitive (from a security perspective) you could URL encode it and pass it as a querystring parameter.

$username = $_GET['username'];
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64708
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"SRIKANT MVS", please check your private messages for an important administrative matter.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic