File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes How to Retrieve a Servlet Session variable in PHP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to Retrieve a Servlet Session variable in PHP" Watch "How to Retrieve a Servlet Session variable in PHP" New topic
Author

How to Retrieve a Servlet Session variable in PHP

Srikant Mantha
Greenhorn

Joined: Mar 30, 2007
Posts: 2
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

Joined: Apr 14, 2004
Posts: 10336

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 ]

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

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'];


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60752
    
  65

"SRIKANT MVS", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
 
subject: How to Retrieve a Servlet Session variable in PHP
 
Similar Threads
Windows username
Login thing
servlets
How to retrieve sessions variables in JSP
Forward to page expecting POST request