Jump to content

Session offset gets lost during header change.


AzeS
Go to solution Solved by AzeS,

Recommended Posts

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 by AzeS
Link to comment
Share on other sites

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.php
Here 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
}
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.