Welcome Guest, Not a member yet? Register   Sign In
Session Lost After Payment Redirect
#1

(This post was last modified: 07-05-2022, 05:04 AM by demyr.)

Hi there,

I don't know if it is a bug or not but I am on local and I have added a payment system on a project. It works fine except for the success part. If the transaction is successful the 3rd party payment system, which I am using, tries to redirect to my result page. (If the message from the 3rd party is success I will display "oh thank you etc", if not I am going to display "there is ... failure etc", you know...)

However, when it redirects to my result page the session is lost, even though I had already signed in, and my own system redirects me to my login screen.

My Route:

This get route with filter doesn't redirect to the page when coming from the payment system:
PHP Code:
$routes->get('/{locale}/user-area/(:num)/my-cart/payment-result/(:num)/''UserAreaController::my_cart_payment_result', ['filter' => 'myUserAreaFilter']); 

If I change the route type to match and surpass my filter, it works but without session :

PHP Code:
$routes->match(['get','post'],'/{locale}/user-area/(:num)/my-cart/payment-result/(:num)/''UserAreaController::my_cart_payment_result'); 

My Filter:
PHP Code:
public function before(RequestInterface $request$arguments null) {
        $locale service('request')->getLocale();
        $msg 'Sign in First Please';

        $session = \Config\Services::session();
        $session_info $session->user_email;
          if($session_info ==''){
            $session->setFlashdata('error'$msg);
            return redirect()->to(site_url($locale.'/login'));
          }

    }//before ends 


My Controller:
PHP Code:
        $session = \Config\Services::session();
        $session_info $session->user_email;

        // I obtain user_id checking user in the session and then I use it in my controller wherever I need

        if($session_info !=''){
           $data['user'] = $this->SiteLib->UserModel->check_if_user_exists($session_info);
           $user_id $data['user']->user_id;
        



So, how can I keep my session data even after the redirect coming from the payment system?
Reply


Messages In This Thread
Session Lost After Payment Redirect - by demyr - 07-05-2022, 03:20 AM



Theme © iAndrew 2016 - Forum software by © MyBB