2017-11-18 172 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] => 
       ) 

     ) 

)