top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Session Vars not staying active in PHP

0 votes

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

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?

posted Aug 3, 2013 by Deepankar Dubey

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

1 Answer

+1 vote

Are you calling session_start() on both pages or at least using a session auto start? Also, is the API returning the data by redirecting the client (browser) or doing a postback?

If the remote server is calling back behind the scenes, then you'll need a workaround and additional processing, or the ability to pass the session ID and assume the client-initiated session (not ideal). If it's all processed by the browser, the redirection should have no bearing, as the session will persist based upon the server-side data and the client-side cookie; the server will have no knowledge of the client's redirection to the payment gateway (nor any remote destination).

answer Aug 3, 2013 by Mandeep Sehgal
Similar Questions
+1 vote

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.

0 votes

I have the following (below) session code at the top of each page.. The 'print_r' (development feature only) confirms that on one particular page I do log out as the session var = (). but, on testing that page via the URL I still get to see the page and all its contents - session var() -.. the page has the following session_start, DOCTYPE Info then containing meta info

error_reporting (E_ALL ^ E_NOTICE);
$userid = $_SESSION['userid'];
$username = $_SESSION['username'];