drydaenth257216154 2013-02-14 14:48
浏览 27
已采纳

拾取已声明的会话变量

Turns out my php.ini file wasn't configured properly. With fatcow (my host) you have to change the .ini file to specify the directory where you are saving session date and include session.save_path=("directory"); prior to session_start();.

You guys were absolutely right. This has been a great learning experience.

I am having trouble with sessions.

On my first page I have declared session variables properly I know because I can print them with in the php file that I declared them in. On the page which the user is forwarded to with my header I try to do the following but nothing prints. Its as if the session_start(); does nothing. I tried Print_R(); and it just prints Array ( ). Here is my code from the page specified in the header- it is a .phtml file.

//HTML code up here
 <?   
session_start();
echo $_SESSION['dentist_first_name'];
Print_r ($_SESSION);
 ?>
//HTML code down here

Is there anything I have to do on the landing page to make sure that the session is continued? I used session_start(); on the original page.

Really confused that my variables aren't getting picked up.

  • 写回答

3条回答 默认 最新

  • dongzhi1949 2013-02-14 14:50
    关注

    session_start() must be called before you output any HTML

     <?   
    session_start();
    ?>
    //HTML code up here
    <?php
    echo $_SESSION['dentist_first_name'];
    Print_r ($_SESSION);
     ?>
    //HTML code down here
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题
  • ¥15 企业资源规划ERP沙盘模拟