2013-05-28 64 views
0

這裏是我用於會話的代碼。php會話不在鏈接上工作

<?php 
    $inactive = 600; 
// check to see if $_SESSION['timeout'] is set 
    if(isset($_SESSION['timeout'])) { 
    $session_life = time() - $_SESSION['timeout']; 
    if($session_life > $inactive) 
    { 
    session_destroy(); 
    } 

    else 
    { 
    echo "<script>function multiclick() 
    { 
    document.getElementById('Image9').style.display='none'; 

    } 
    </script>"; 
    } 
    } 
    $_SESSION['timeout'] = time(); 
    ?> 

actuly我想,當我的鏈接點擊一次將hide.but它也不working.here是我的網頁鏈接和鏈接,我的工作就是愛它。 http://shoppingmore.com.hk/index.php?option=com_shopsearch&view=shopdetails&shop_id=139

請任何help.thanks在高級。

+0

你開始會話? 'if(!isset($ _ SESSION)){session_start(); }' –

+0

是sessoin已經開始在頁面的頂部? –

回答

2

使用session_start()在代碼

<?php 
    session_start(); 
    $inactive = 600; 
+0

會話是在頁面頂部啓動的。實際上,我希望該按鈕一旦點擊後消失? –

+0

當用戶點擊愛它然後你只是爲這個頁面創建一個會話($ _SESSION ['愛'] [139] =真)其中139是頁面ID。然後,只需爲愛情設定一個條件 - 如果(!$ _ SESSION ['愛'] [$ shop_id])回聲'愛它'; – HADI

0

頂部,你必須寫

session_start(); 

before if(isset($_SESSION['timeout'])) { ... 
+0

會話已經開始在頁面的頂部? –