使用PHP会话变量日期设置默认的Datepicker日期

I'm setting the date in the Datepicker by using PHP.

The date is set using $_REQUEST and I store this in a session variable.

$date = $_REQUEST['date'];
$_SESSION['date']=$date;

The session variable and date is getting set as required.

I set the default datepicker value by using the following PHP script:

<div id="divDatePicker" class="input-append datepicker">
                  <?php if($_SESSION['date']){ ?>
                <input id="filter-date" size="16" type="date" value="<?php echo $_SESSION['date'];?>"/>
                  <?php } else { ?>
                <input id="filter-date" size="16" type="date" value="<?php echo date('Y-m-d');?>"/>
                  <?php } ?>
                  </div>

So if the date isn't set by default today's date shows up which works just fine as well.

The problem arises when I navigate to another page.

So my datepicker is on 1.php. When I go to 2.php and navigate back to 1.php via breadcrumbs even though the session variable for date is still set (I can see this using var_dump) the Datepicker does not get set. So what shows up is mm/dd/yyyy in the Datepicker.

Why isn't it getting set to $_SESSION['date'] on navigating back?

To display the value in input type date create variable and give this variable the value of sessionvalue="<?php echo $date;?>"