$ _SESSION无法正常工作

Does anybody know why the following code doesn't work properly?

function LinksPage()
{
    $ClickedWord = $_GET['clickedword'];
    foreach($_SESSION['Links'] as $key=>$value)
    { 
        if ($key == $ClickedWord)
        echo $key."  ".$value.' <br />';
    }
}

When I check $ClickedWord, $_SESSION['Links'], I see that there is a key in $_SESSION['Links'] that matches $ClickedWord but when I run the program if doesn't generate output.

This code is just fine. What's wrong is either $_SESSION['Links'] or $_GET['clickedword']. Add the following debugging code in LinksPage:

echo '$_GET["clickedword"]: ';
var_export($_GET['clickedword']);
echo '$_SESSION: ';
var_export($_SESSION);

Most likely, the $_SESSION['Links'] hasn't been set for the session in use, or you set $_SESSION['links'] (with a lower-case L) instead.

nasi, Try this

$_GET['clickedword'] = "http://stackoverflow.com/questions/7454193/session-doesnt-work-properly";
$ClickedWord = @$_GET['clickedword'];
$_SESSION['Links'] = "http://stackoverflow.com/questions/7454193/session-doesnt-work-properly";
foreach($_SESSION as $key=>$value)
{ 
    if ($value == $ClickedWord)
    echo $key."  ".$value.' <br />';
}

Replace:

if ($key == $ClickedWord)

with

if ($value == $ClickedWord)