I am working on a project in CodeIgniter 3. A user can make an online payment via paytm payment gateway on the booking page.
After the user completes the payment process, he is redirected back to my website which is handled by a response controller where I am updating the booking details like the payment method and booking status using the booking id stored in the session. The session data is not available when I try to access it in this controller.
This is my session configuration:
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = BASEPATH . 'cache/sessions/';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
This is the controller which handles the response sent by payment gateway
public function paytmResponse(){
$this->load->model('booking_model');
$this->load->model('user_model');
$this->load->library('paytm');
$paytmChecksum = isset($_POST["CHECKSUMHASH"]) ? $_POST["CHECKSUMHASH"] : "";
$this->booking_model->updatePaymentType($_SESSION['bid'], 'online');
$valid_checksum = $this->paytm->verifyChecksum($_POST, $paytmChecksum);
if($valid_checksum){
if($_POST["STATUS"] == "TXN_SUCCESS"){
$this->booking_model->savePaymentDetails($_SESSION['bid']);
$this->booking_model->updateBookingStatus($_SESSION['bid'], 'pending');
$status = 1;
}
else{
$this->booking_model->updateBookingStatus($_SESSION['bid'], 'failed');
$status = 0;
}
}
else{
$this->booking_model->updateBookingStatus($_SESSION['bid'], 'failed');
$status = 2;
}
if($status == 1){
redirect('booking/success');
}
else{
$_SESSION['booking_error'] = 'Payment failed';
redirect('booking/failure');
}
}
I am using the codeigniter session library, php version 7.2
"The session data is not available when I try to access it in this controller."
, edit your question with some essential code to sample your issue. Which CI, php version are you using, are you using native $_SESSION or $session->get() to retrieve the session data?, etc... – Vickel