未定义的索引:user_name

时间:2014-03-30 06:28:09

标签: php

当我尝试使用$ _SESSION中的user_name时,我收到错误

  

'未定义的索引:user_name'

CODE:

  $_SESSION['signed_in'] = true;

  while ($row = $query1->fetch(PDO::FETCH_ASSOC))
  {
    $_SESSION['user_id']    = $row['user_id'];
    $_SESSION['user_name']  = $row['user_first_name'];
  }

  echo 'Welcome, ' . $_SESSION['user_name'] . '. <a href="index.php">Proceed to the overview page to see your tasks</a>.';  

1 个答案:

答案 0 :(得分:1)

添加session_start();在页面顶部开始会话。