Solarpitch Posted June 30, 2008 Share Posted June 30, 2008 Hi, I'm having a little trouble setting the value of a session. My syntax and that is right but the session just wont take the value of the variable. I had a similar problem with this ages ago and I had to use ob_start() and ob_end_flush(); within the code to get it to work. The server is set up correctly to accept php sessions as it works on other sites so its something specific to this code it seems. Here's the code.. <?php session_start(); include("params/params.php"); $date = $_GET['date']; $_SESSION['date'] = $date; // I've tested that it is getting the date and it is. When I reload the page and try to print the value of the session, it prints noting ?> Link to comment https://forums.phpfreaks.com/topic/112589-session-setting-question/ Share on other sites More sharing options...
revraz Posted June 30, 2008 Share Posted June 30, 2008 Let's see the second page that you try to recall the session variable with. Link to comment https://forums.phpfreaks.com/topic/112589-session-setting-question/#findComment-578211 Share on other sites More sharing options...
Solarpitch Posted June 30, 2008 Author Share Posted June 30, 2008 Its the same page, I just submit a form and try to test it by printing it... <?php $process = isset($_POST['process']) ? $_POST['process'] : ''; if ($process != "execute") { //not being submitted... } else { $teedate = $_SESSION['date']; echo $teedate; insert($teedate, $gui1, $gui2,....); } ?> Link to comment https://forums.phpfreaks.com/topic/112589-session-setting-question/#findComment-578215 Share on other sites More sharing options...
revraz Posted June 30, 2008 Share Posted June 30, 2008 Then post the whole page, bits and pieces make it difficult to find the error. Link to comment https://forums.phpfreaks.com/topic/112589-session-setting-question/#findComment-578216 Share on other sites More sharing options...
Solarpitch Posted June 30, 2008 Author Share Posted June 30, 2008 <?php session_start(); include("params/params.php"); error_reporting(0); $teedate = $_GET['teedate']; $_SESSION['teedate'] = $teedate; $teetime = $_GET['teetime']; $_SESSION['teetime'] = $teetime; $membertype = $_GET['type']; if($membertype == "visitor") { header("Location:booking_4.php?teedate=".$teedate."&teetime=".$teetime.""); } else { $group = "member"; } $process = isset($_POST['process']) ? $_POST['process'] : ''; if ($process != "execute") { $slot = 1; //not being submitted... } else { echo $_SESSION['teetime']; echo $_SESSION['teedate']; $gui1 = $_POST['gui1']; $gui2 = $_POST['gui2']; $gui3 = $_POST['gui3']; $gui4 = $_POST['gui4']; //$teedate = $_SESSION['teedate']; //$teetime = $_SESSION['teetime']; $session = $_POST['session']; if($gui1!=""){ $get_name1 = get_name($gui1); foreach($get_name1 as $e) { $member_name1 = $e[0]; } if($member_name1 == ""){$error=1; echo "invalid gui";} } if($gui2!=""){ $get_name2 = get_name($gui2); foreach($get_name2 as $e) { $member_name2 = $e[0]; } if($member_name2 == ""){$error=1; echo "invalid gui";} } if($gui3!=""){ $get_name3 = get_name($gui3); foreach($get_name3 as $e) { $member_name3 = $e[0]; } if($member_name3 == ""){$error=1; echo "invalid gui";} } if($gui4!=""){ $get_name4 = get_name($gui1); foreach($get_name4 as $e) { $member_name4 = $e[0]; } if($member_name4 == ""){$error=1; echo "invalid gui";} } if($error == 1) { } else { if($session == "current") { current_session($teedate, $teetime, $gui1, $gui2, $gui3, $gui4, $member_name1, $member_name2, $member_name3, $member_name4); } if($session == "new") { new_session($teedate, $teetime, $gui1, $gui2, $gui3, $gui4, $member_name1, $member_name2, $member_name3, $member_name4); } } } ............... // Then the forms looks like this echo "<form name='form1' method='post' action='booking_3.php'> <label>Slot 1: $name1</label><br> $input1<br><br> <label>Slot 2: $name2</label><br> $input2<br><br> <label>Slot 3: $name3</label><br> $input3<br><br> <label>Slot 4: $name4</label><br> $input4<br><br> <input type='hidden' name='process' value='execute'> <input type='hidden' name='session' value='current'> <input type='submit' name='Submit' value='Make Reservation' onClick='javascript:bar1.showBar()'> </form> "; ?> Link to comment https://forums.phpfreaks.com/topic/112589-session-setting-question/#findComment-578221 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.