AzeS Posted February 28, 2017 Share Posted February 28, 2017 (edited) Dear Community,I have a problem with declaring an offset from the session, this offset is generated in a function declared as public, so far so good, it consists of two further arrays which are also successfully set, the whole thing is triggered via an activation php Which is called from the original page, now comes the real problem of the whole thing; This offset disappears directly after the header argument in the activating php, what am I doing wrong? It would be a lot of code that I would have to take here, so I ask for theories, links or suggestions which to have to optimize the code. I'm assuming that the varible is lost during the header change. So what are the most common errors that occur when declaring a session? Regards AzeS. Edited February 28, 2017 by AzeS Quote Link to comment https://forums.phpfreaks.com/topic/303310-session-offset-gets-lost-during-header-change/ Share on other sites More sharing options...
Jacques1 Posted February 28, 2017 Share Posted February 28, 2017 I have no idea what you're talking about. “Offset”? “Header argument”? Show us real code and hard facts (debug outputs, screenshots, ...) instead of telling some vague story. We're programmers, not mind readers. Quote Link to comment https://forums.phpfreaks.com/topic/303310-session-offset-gets-lost-during-header-change/#findComment-1543499 Share on other sites More sharing options...
AzeS Posted February 28, 2017 Author Share Posted February 28, 2017 ordersys.php public function order_refund_contract_assignment_validation($ref_num,$code) { $sql = $this->db->prepare("SELECT code,attemps FROM refund_keys WHERE reference=:e AND active=:f"); try { $sql->execute(array(':e' => $ref_num, ':f' => 1)); $res = $sql->Fetch(PDO::FETCH_ASSOC); } catch (PDOException $ex) { echo $ex->getMessage(); return 0; } if ($res['code'] == md5($code)) { if ($res['attemps'] != 5) { $sql = $this->db->prepare("SELECT order_pid FROM orderbase WHERE order_id=:e"); try { $sql->execute(array(':e' => $ref_num)); $res = $sql->Fetch(PDO::FETCH_ASSOC); $counter = 0; $procces_list_0 = split("\n", $res['order_pid']); foreach ($procces_list_0 as $row) { if ($row != "") { $current = split(":", $row); $items[$counter] = $current[1]; $items_quant[$counter] = $current[9]; } $counter = $counter + 1; } $counter = 0; $_SESSION['refund_cart'] = array('items' => $items,'quant' => $items_quant); $res['msg'] = "you can now edit your privios cart to assign an refund request."; $res['stmt'] = 1; return $res; } catch (PDOException $ex) { echo $ex->getMessage(); return 0; } } else { $res['msg'] = "due to security reasons the code is not longer valid, please contact the support via email or whapp for fruther information and advise."; $res['stmt'] = 0; return $res; } } else { $sql = $this->db->prepare("UPDATE refund_keys SET attemps=:e WHERE reference=:f"); try { $sql->execute(array(':e' => $res['attemps'] +1, ':f' => $ref_num)); $res = $sql->Fetch(PDO::FETCH_ASSOC); } catch (PDOException $ex) { echo $ex->getMessage(); return 0; } $res['msg'] = "wrong code please try again, you have " . 5 - $res['attemps'] . " attemps left."; $res['stmt'] = 0; return $res; } } activation.phpHere i can still dump the session but after the header argument the var gets lost. <?php require_once 'dbconnect.php'; if (isset($_GET['type'])) { var_dump(trim(strip_tags($_GET['type']))); switch (trim(strip_tags($_GET['type']))) { case 0: $_SESSION['refund_code'] = trim(strip_tags($_GET['code'])); $_SESSION['refund_id'] = trim(strip_tags($_GET['id'])); $res = $ordersys->order_refund_contract_assignment_validation(trim(strip_tags($_GET['id'])),trim(strip_tags($_GET['code']))); header("Location: Bestellungen.php?rmsg=" . $res['msg'] . "&list=" . $res['stmt']); # Here it gets lost break; case 1: $res = $ordersys->order_refund_contract_assignment(trim(strip_tags($_SESSION['refund_id'])),trim(strip_tags($_SESSION['refund_code']))); header("Location: Bestellungen.php?rmsg=" . $res); break; case 2: break; default: # code... break; } } ?> <!--<script type="text/javascript"> history.go(-1) </script> <noscript> <?php #header("Location: msg.php?restricted") ?> </noscript> refund.php: if (isset($_POST['adj_ref_car_exe'])) { $ref_car_off_num = trim(strip_tags($_POST['ref_car_off_num'])); $ref_car_dat_qua = trim(strip_tags($_POST['ref_car_dat_qua'])); $_SESSION['refund_cart']['quant'][$ref_car_off_num] = $ref_car_dat_qua; # missing session variable } Quote Link to comment https://forums.phpfreaks.com/topic/303310-session-offset-gets-lost-during-header-change/#findComment-1543501 Share on other sites More sharing options...
Solution AzeS Posted March 1, 2017 Author Solution Share Posted March 1, 2017 http://stackoverflow.com/questions/17242346/php-session-lost-after-redirect Quote Link to comment https://forums.phpfreaks.com/topic/303310-session-offset-gets-lost-during-header-change/#findComment-1543539 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.