top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Session persistence with a php script

+1 vote
591 views

I am trying to figure out if I can run my sessionpersistence script that I run with Apache to see if sessions persist between two tomcat sites on two separate servers. The load balancer has session persistence enabled but Iam unsure how to test it. My thought was that I would just add the following php script to check, but apparently I am doing something wrong. The script is this:

but it seems not to like it if I add it from the webapps directory or from inside a directory under that. Is there some special trick to running php from inside tomcat ? I have tomcat set up the same on both servers and am fronting it with Apache if that adds options for me.

posted Aug 21, 2013 by Garima Jain

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

1) Tomcat is meant to run Servlet based Java apps, not PHP. Use Apache HTTPD to run PHP.
2) Just use the manager application that is bundled with Tomcat to check sessions.
https://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html

answer Aug 21, 2013 by Satish Mishra
+1 vote

You really don't want to run PHP from inside of Tomcat. It can be done, and probably the cleanest way to do it is to add the executable init-param to the cgi servlet and point it to php.

  1. copy the cgi servlet definition out of web.xml and add it to your web.xml
  2. add the init-param for PHP
  3. make sure to mark your context as privileged

This will make your application Tomcat-specific. You could edit the distributed web.xml in $CATALINA_BASE/conf, but then that Tomcat could only run PHP (and not the default perl).

answer Aug 21, 2013 by Sanketi Garg
Similar Questions
0 votes

I am having trouble with session vars. I'm trying to implement the credit card direct pay method outlined here...

http://developer.authorize.net/api/dpm/

Basically, page 1 is my form that goes outside my site to the cc gateway company then comes back with a result... (PG2)

Problem: if I try to create session vars on page 1 - they don't work on page 2.

Am I correct in thinking that when this process leaves my site and goes to the gateway, then returns, it is similar to creating a new session and that is why the session vars don't remain active?

0 votes

I want to write online user module for my site and I want to check $_SESSION['userID'] to find all users id who loged in but when I echo this code its return only current user detail how I can see all sessions?

foreach($_SESSION as $k => $v)
{
echo $k."----------".$v;
}

or how I handle online users?

...