-1

i am creating ticket booking website using some api , i use json for get & post values and creating php session's to pass data's to other pages, page 1 : creating session's page 2 : payment gateway (i checked session's payment page it works fine) page 3 : success page (after redirecting from payment gateway to my server page the session's are showing null values in chrome browser but works fine in Firefox). all suggestion's are welcome.thanks in advance. some code

<?php
session_start();
if(isset($_REQUEST['blockTicketId'])!=''){
    $rootId= $_REQUEST['ruteId'];
    if( $_REQUEST['dropPoint_'.$rootId]!=''){ 
        $board = explode("_", $_REQUEST['dropPoint_'.$rootId]); 
    } 
    $_SESSION['formcity']=$_REQUEST['fromCity'];
    $_SESSION['tocity']=$_REQUEST['toCity'];
    $_SESSION['dateofjurny']=$_REQUEST['fromDate'];
    $_SESSION['pickup']=$board[0];
    $_SESSION['pickupTime']=$board[2];      
    $_SESSION['travelName']=$_REQUEST['travelNmae'];
    $_SESSION['seat']=$_REQUEST['selectedSeat_'.$rootId];
    echo $_SESSION['blockTicketNumber']=$_REQUEST['blockTicketId'];
    $_SESSION['mobno']=$_REQUEST['bookerMob'];
    $_SESSION['mailid']=$_REQUEST['bookerEmail'];
    $_SESSION['user']=$_REQUEST['UserName_1'];
    $_SESSION['amnt']=$_REQUEST['selectedSeatAmnt_'.$rootId];
?>

<html>
  <head>
  <script>
  function submitPayuForm() {
    var payuForm = document.forms.payuForm;
    payuForm.submit();
  }
  </script>
  </head>
  <body onLoad="submitPayuForm()">
    <form action="PayUMoney_form.php" method="post" name="payuForm">
      <table>
        <tr>
          <td></td>
        </tr>
        <tr>
          <td></td>
          <td><input style="visibility:hidden" name="amount" value="<?php echo "1"; ?>" /></td>
          <td></td>
          <td><input style="visibility:hidden" name="firstname" id="firstname" value="<?php echo $_REQUEST['UserName_1']; ?>" /></td>
        </tr>
        <tr>
          <td></td>
          <td><input style="visibility:hidden" name="email" id="email" value="<?php echo $_REQUEST['bookerEmail']; ?>" /></td>
          <td></td>
          <td><input style="visibility:hidden" name="phone" value="<?php echo $_REQUEST['bookerMob']; ?>" /></td>
        </tr>
        <tr>
            <td colspan="4"><input type="submit" style="visibility:hidden" value="Submit" /></td>
        </tr>
      </table>
    </form>
  </body>
</html>

<?php 
}
?>
Halvor Holsten Strand
  • 19,829
  • 17
  • 83
  • 99
user3292198
  • 1
  • 1
  • 2
  • 2
    Can you share some of the code with us? How are you storing the session? – Andrew Feb 10 '16 at 18:09
  • i add some code in my question – user3292198 Feb 10 '16 at 18:17
  • Php session independs from user's browser. Is session page, gateway page and succes page on the same domain name, i.e. site / server? I'm suspect that gateway page do something like `session_destroy()`, but it can be wrong. Anyway shown code is not enough. – Wizard Feb 10 '16 at 18:21
  • yes we call this ($_SESSION['blockTicketNumber'] ) session's in final success page for conforming the ticket and show the booked ticket details, but after redirecting from payment gateway it will show null values. – user3292198 Feb 10 '16 at 18:25

2 Answers2

0

Reason for this behaviour is that session cookies do not have an expiration date and are erased when the browser is closed or the website is left. So the cookie will not be present any more when the user returns from the payment site.

Solution to this is to incorporate some identification attribute in the query string of the callback link. You will also have to store the session data together with the identification attribute on your server.

syck
  • 2,984
  • 1
  • 13
  • 23
0

i have not tried but you can try to pass "session variable" through paymnet gateway redirection page from your website to payumoney gateway sucess page./

example: 1)your website payment form + store your session in a GLOBAL session variable ($SESSION[var]="abc") + and also store your session variable in (the array parameters given by payment gateway ) -> (2) gateway page -> (3) access your session variable again from passed array.

Note:- do not depend on session_start() function on gateway success page. tell me if it works.

Nitish
  • 109
  • 1
  • 2
  • 11