I'm using OpenCart 3.0.3.2
I want to check if the user is logged in or not in a file called test.php
located outside opencart folder.
for example, if the shop URL is http://www.example.com/shop
then the PHP file to check is in http://www.example.com/test.php
I saw in this link someone is asking the same question before 2 years. check user is logged in to opencart or not
This was for version 2.x
, and when I try it did not work.
So how to do it in version 3.0.3.2
?
I have tried different things with the session but nothing works.
Just tested both those answers combined. Works perfect. Check the following:
$_SESSION
.Lets collect all that solutions together. Open from your OpenCart 3 root catalog/controller/common/header.php and find
class ControllerCommonHeader extends Controller {
public function index() {
add below
session_start();
$_SESSION['opencart'] = $this->session->data;
Now go to your test.php and add
<?php
if(!empty($_SESSION['opencart']['customer_id'])){
// User Loged in
}
?>