2017-11-18 190 views
0

我是opencart的新手。我有我的基本的PHP代码http://localhost/testphp通过php文件访问opencart的会话数据

和我的opencart安装在http://localhost/opencart。我想要做的是在testphp,我有一个页面,其中我want to check that if any user is logged in or not at opencart

如果在随后登录我想执行X功能

,并在随后它没有登录要执行y功能

我试图登录到Opencart的和testphp试图print_r($_SESSION)。 它返回空白。我该如何执行此操作?请帮我

+0

没有在Opencart的数据库中的'customer_online'表。请参阅admin \ model \ report \ customer.php中的'getCustomersOnline'函数 – DigitCart

回答

1

如果你使用的是localhost,那么你可以试试这个。 或同一托管帐户或的cPanel

进入目录/控制器/通用/ header.php文件

之前 “公共功能指数(){” 添加该代码

class ControllerCommonHeader extends Controller { 
    public function index() {  
      session_start(); 
      $_SESSION['opencart'] = $this->session->data; 

您必须打印阵列http://localhost/testphp 代码:

<?php 
session_start(); 
echo '<pre>'; 
print_r($_SESSION); 
echo '</pre>'; 
?> 

你的输出就会

Array 
(
    [opencart] => Array 
     (
      [language] => en-gb 
      [currency] => USD 
      [customer_id] => 2 
      [shipping_address] => Array 
       (
        [address_id] => 2 
        [firstname] => Prashant 
        [lastname] => Bhagat 
        [company] => 
        [address_1] => Surat 
        [address_2] => 
        [postcode] => 395003 
        [city] => Surat 
        [zone_id] => 1485 
        [zone] => Gujarat 
        [zone_code] => GU 
        [country_id] => 99 
        [country] => India 
        [iso_code_2] => IN 
        [iso_code_3] => IND 
        [address_format] => 
        [custom_field] => 
       ) 

     ) 

)