php - Is it possible to bindParam a Session variable? -


what want achieve when user logs in users id saved session value, , when logged in user selects date products display based on date selected showing customer.

to confirm there 2 issues here: 1, how save user id in session?, 2, how bindparam sessionid?

here have in terms of code:

when user logs in:     $_session['customer_loggedin'] = $row['id'];  not display id on row? 

when user selects date, ajax sends to:

session_start();     include('db_config.php');     $datepicker = $_post['dateorderpicker'];      $sql = "select * orders deliverydate = ? , cusomerid= ?";      $stmt = $conn->prepare($sql);     $stmt->bindparam(1, $datepicker, pdo::param_str);      // how bind param session id?      $stmt->execute();     while ($row = $stmt->fetch(pdo::fetch_assoc))     {            ?>             <div class="col-sm-4 col-md-4">                 <div class="content-boxes style-two top-column clearfix animated flipiny" style="opacity: 1;">                 <div class="content-boxes-text">                     <h4><?php echo $row['itemname']; ?></h4>                 <img src="../wholesale/img/sourdough.jpg" class="img-reponsive">                 <p>our best seller.  full of flavour.</p>                 <form class="form-inline pull-right">                 <div class="form-group">                 <label class="sr-only" for="exampleinputamount">qty</label>                 <div class="input-group">                 <input type="number" class="form-control" id="exampleinputamount" placeholder="<?php echo $row['qty']; ?>">                 </div>                 </div>                 <button type="submit" class="btn btn-primary">update</button>                 </form>                 </div>                </div>               </div>         <?php     } 

if there other information need please feel free ask. still learning if see not right please let me know can better php :) thanks

    if($login && $password)     {         $sql = "select * customer (code=:code or phone=:phone or businessname=:businessname or email=:email) , password=:password";         $stmt = $conn->prepare($sql);         $stmt->bindvalue(':code', $login, pdo::param_str);         $stmt->bindvalue(':phone', $login, pdo::param_str);         $stmt->bindvalue(':businessname', $login, pdo::param_str);         $stmt->bindvalue(':email', $login, pdo::param_str);         $stmt->bindvalue(':password', $password, pdo::param_str);         $stmt->execute();         $num = $stmt->fetchcolumn();         if($num > 0)         {         $_session['customer_loggedin'] = $row['id'];             header('location:order.php');         }         else{             header('location:index.php');             $_session['errmsg'] = 'incorrect login details';             die;         }     } }   

how save user id in session?

you have start session , set other variable, have in question. add session_start() before it:

session_start(); $_session['customer_loggedin'] = $row['id']; 

how bindparam sessionid?

again, it's binding other parameter. once call session_start() set session variables placed $_session array.

$stmt->bindparam(2, $_session['customer_loggedin'], pdo::param_int);