php - Session Doesnt work first time (want explanation ) -
hello seen lot of question session doesn't working first time. couldn't see explanation on question , why doesn't working first time happening during sessioning. mine others first time doesn't working after works fine.
this php sessioning.
session_start(); $personname=$_get['personname']; $surname=$_get['surname']; $testxml=$_get['testxml']; $testdate=$_get['testdate']; $testpkid='0000000000000000000000000000'; include('dbconnect.php'); $proc = "{call p_set_test(?,?,?,?,?,?,?,?,?)}"; $params = array(array($testdate,sqlsrv_param_in), array(0,sqlsrv_param_in), array($personname,sqlsrv_param_in), array($surname,sqlsrv_param_in), array($testxml,sqlsrv_param_in), array('',sqlsrv_param_in), array(101,sqlsrv_param_in), array(10,sqlsrv_param_in), array($testpkid, sqlsrv_param_out) ); $result = sqlsrv_query( $conn, $proc, $params); if( $result === false ) { echo "error in executing statement 3.\n"; die( print_r( sqlsrv_errors(), true)); $message2 = "aldaatai"; echo "<script type='text/javascript'>alert('$message2 ' + $testpkid);</script>"; } $_session['idpktestsession'] = $_post["idpktest"] = $testpkid; $_session['persontestname'] =$_post['persontrollname'] = $personname; $_session['persontestlastname'] =$_post['persontrolllastname'] = $surname;
this getting value sessioned values
<?php include('dbconnect.php'); session_start(); $diskuserid = $_session['idpktestsession']; $diskusername = $_session['persontestname']; $diskuserlastname = $_session['persontestlastname']; $diskuserlastname = mb_substr($diskuserlastname, 0, 1); ?> <?php $proc = "{call p_rpt_pattern(?,?)}"; $params = array($diskuserid,'m'); $procarr = array(); $result = sqlsrv_query( $conn, $proc, $params); while ($row = sqlsrv_fetch_array($result)) {?> <tr> <td><?php echo $row['patterncode']?></td> <td><i class="fa fa-chevron-right rightarrow" > </i></td> <td><?php echo $row['patterndesc']?></td> </tr> <?php } ?>
this statement written incorrect:
$_session['idpktestsession'] = $_post['idpktest'] = $testpkid;
if want assign value can rewrite above statement this
$_session['idpktestsession'] = $_post['idpktest'];
and if want concatenate 2 values can rewrite this
$_session['idpktestsession'] = $_post['idpktest'] . ','. $testpkid;
Comments
Post a Comment