0

My project information:

My page loses all session (shopping cart, user login...) when page redirects from E-xact Gateway after customer did purchasing. This issues didn't happen before. It happened after integrating phpdotenv into my project.

Scenario 1:

  • Start page: session file name AAA
  • Cart was empty, I added item and do purchasing, after page redirected from E-xact (payment successfully). All page's sessions were gone. Session file BBB was created and of course it was empty.
  • On session file BBB, logged in again, go back to cart and do purchasing again for the item that I already added before and it was successful.

Scenario 2:

  • On session file BBB, I did adding cart, payment again as same as Scenario 1. It was created session file CCC and went back the problem as Scenario 1.

I tried: (but the issues still happens)

  • Truncate my databases.
  • Clear all session's files
  • Installing new project
  • Change session.gc_maxlifetime 1440 to session.gc_maxlifetime 3600
  • Comment phpdotenv
  • Comment all $this->session->destroy().
  • Send and get session back by session ID:
logger("SSID before: ".$this->session->getId(), 0);
$ssId = $this->request->getQuery("ssId");
session_id($ssId);
session_start();
logger("SSID after: ".$this->session->getId(), 0);

// Log info
[INFO][2020/08/24 10:27:22 AM]: SSID before: 82119875f4e94fbf4d34a5d14515c5c9
[INFO][2020/08/24 10:27:22 AM]: SSID after: 8229b3e8e644c5a3b7a8c89ab0a9c778
[INFO][2020/08/24 10:27:49 AM]: SSID before: 82119875f4e94fbf4d34a5d14515c5c9
[INFO][2020/08/24 10:27:49 AM]: SSID after: 82119875f4e94fbf4d34a5d14515c5c9

My initial script for session

$di->setShared('session', function () {
    $session = new SessionAdapter();
    $session->start();
    return $session;
});

I know that I am facing this issue because Phalcon created new session file after redirecting from another page. However, I din't know how and when does Phalcon framework create new session file?

Does anyone have any ideas?

TommyDo
  • 663
  • 8
  • 23
  • 1
    I don't believe Phalcon creates or manages sessions - it ties into PHP's built-in session management. All Phalcon does is create some easier-to-use wrappers around the functionality. Try swapping out all the Phalcon session code with built-in calls and see if the problem persists. My guess is this is an issue with the process, not with Phalcon. – Quasipickle Aug 24 '20 at 20:00

1 Answers1

0

Finally, It was FAVICON !!!

I fixed this issue after reading this post HERE

All I need to do are:

  • Check favicon.ico link works,
  • And add this line to .htaccess file
RewriteRule ^favicon.ico$ favicon.ico [L]

In my special case, my former coworker wrote this favicons link looks like this:

<link rel="icon" href="{{ image_url }}/favicon.ico" type="image/x-icon">

I have to changed it to

<link rel="icon" href="/public/images/favicon.ico" type="image/x-icon">

Don't forget CTRL + SHIFT + F5 to refresh page.

TommyDo
  • 663
  • 8
  • 23