feat: replace cookie to store tracking code with native php session
This commit is contained in:
@@ -29,7 +29,6 @@ namespace EP\EpTrack\Middleware;
|
||||
|
||||
use Doctrine\DBAL\DBALException;
|
||||
use EP\EpProducts\Traits\DbConnectionTrait;
|
||||
use EP\EpProducts\Utility\CookieUtility;
|
||||
use Exception;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
@@ -102,7 +101,7 @@ class TrackingMiddleware implements MiddlewareInterface
|
||||
$trackingCode = $redirect['tracking_code'];
|
||||
|
||||
if (!empty($trackingCode)) {
|
||||
CookieUtility::setPaCookie($trackingCode);
|
||||
$this->saveTrackingCodeToSession($trackingCode);
|
||||
}
|
||||
|
||||
$targetPage = $redirect['target_page_uid'];
|
||||
@@ -159,7 +158,7 @@ class TrackingMiddleware implements MiddlewareInterface
|
||||
|
||||
$urlItems = GeneralUtility::trimExplode('/', $path, true);
|
||||
$code = array_pop($urlItems);
|
||||
CookieUtility::setPaCookie($code);
|
||||
$this->saveTrackingCodeToSession($code);
|
||||
$uri = '/';
|
||||
if (count($urlItems) > 0) {
|
||||
$uri = '/' . implode('/', $urlItems) . '/';
|
||||
@@ -170,4 +169,13 @@ class TrackingMiddleware implements MiddlewareInterface
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
private function saveTrackingCodeToSession(string $trackingCode)
|
||||
{
|
||||
if ('' === session_id()) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
$_SESSION['ep_trk'] = $trackingCode;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user