dongmiao4733 2013-07-16 18:41
浏览 49
已采纳

如何允许仅在初始页面加载时或在请求时存在时设置会话变量?

I want to define only once, on the page load, the session variable $SESSION_estatus. Then I want to update it ONLY when a request variable is passed on the URL. Currently if the $_REQUEST['estatus'] variable is not present, it is updating the $SESSION_estatus back to all. In other words, I am trying to maintain the state of the selection of $SESSION_estatus when it is not being passed on the URL. I hope that makes more sense.

My code

if(! isset($SESSION_estatus) ){
       $SESSION_estatus = 'all';    
}

if(isset($_REQUEST['estatus'])){
       $SESSION_estatus = $_REQUEST['estatus'];
}

thank you.

  • 写回答

2条回答 默认 最新

  • duanmiao6695 2013-07-16 18:54
    关注

    The session variable is $_SESSION, I hope that helps you

    if(!isset($_SESSION['estatus']) ){
       $_SESSION['estatus'] = 'all';    
    }
    
    if(isset($_REQUEST['estatus'])){
       $_SESSION['estatus'] = $_REQUEST['estatus'];
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services