PHP session saving array with POST values -


first sorry english.

i have weird problem using php $_session object. spent 2 days without find solution. triying save multidimensional array stores post values. create array values , create multidimensional array containing arrays.

page 1 (setvalues in multi array ans save in session)-> -> page 2 read session.

my code page 1:

first, save post values object property , validate them.

public function validatedata(){          $this->nombres=$_post["nombre"];         $this->imp_nombres=$_post["imp_nombre"];         $this->numeros=$_post["numero"];         $this->imp_numeros=$_post["imp_numero"];         $this->tallas=$_post["talla"];         $this->cantidades=$_post["cantidad"];         $this->productos=$_post["products"];         $this->equipos=$_post["equipo"];           if(wsi_funtions::comparesizes($this->nombres,$this->imp_nombres,$this->numeros,$this->imp_numeros,$this->tallas,$this->cantidades,$this->productos,$this->equipos))         {             $this->isvalidmodel=true;             $this->saveproductsvalues();          }         else{           $this->isvalidmodel=false;           $this->errormessage="los datos no son correctos. los parametros no coinciden";         }  } 

if data ok, save values:

public function saveproductsvalues() {       $this->productsvalues=array();     $this->productsvalues["names"]=$this->nombres;     $this->productsvalues["imp_nombres"]=$this->imp_nombres;     $this->productsvalues["numeros"]=$this->numeros;     $this->productsvalues["imp_numeros"]=$this->imp_numeros;     $this->productsvalues["tallas"]=$this->tallas;     $this->productsvalues["cantidades"]=$this->cantidades;     $this->productsvalues["productos"]=$this->productos;     $this->productsvalues["equipos"]=$this->equipos;   } 

then save in session :

public function savesessionvalues() {     $_session['customer'] = $this->customerobject;     $_session['productsvalues'] =$this->productsvalues;     echo var_dump($_session['productsvalues']);  } 

the savesessionvalues echo print this:

array(8) { ["names"]=> array(12) { [0]=> string(0) "" [1]=> string(12) "Ángel hdez." [2]=> string(11) "vujasinovic" [3]=> string(4) "abia" [4]=> string(10) "mutakabbir" [5]=> string(8) "petrovic" [6]=> string(5) "dobos" [7]=> string(4) "homs" [8]=> string(6) "castro" [9]=> string(0) "" [10]=> string(0) "" [11]=> string(0) "" } ["imp_nombres"]=> array(12) { [0]=> string(0) "" [1]=> string(1) "1" [2]=> string(1) "1" [3]=> string(1) "1" [4]=> string(1) "1" [5]=> string(1) "1" [6]=> string(1) "1" [7]=> string(1) "1" [8]=> string(1) "1" [9]=> string(0) "" [10]=> string(0) "" [11]=> string(0) "" } ["numeros"]=> array(12) { [0]=> string(1) "7" [1]=> string(1) "8" [2]=> string(1) "9" [3]=> string(0) "" [4]=> string(2) "11" [5]=> string(2) "12" [6]=> string(2) "18" [7]=> string(2) "19" [8]=> string(2) "22" [9]=> string(1) "5" [10]=> string(2) "33" [11]=> string(0) "" } ["imp_numeros"]=> array(12) { [0]=> string(1) "1" [1]=> string(1) "1" [2]=> string(1) "1" [3]=> string(0) "" [4]=> string(1) "1" [5]=> string(1) "1" [6]=> string(1) "1" [7]=> string(1) "1" [8]=> string(1) "1" [9]=> string(1) "1" [10]=> string(1) "1" [11]=> string(0) "" } ["tallas"]=> array(12) { [0]=> string(4) "xxxl" [1]=> string(3) "xxl" [2]=> string(2) "xl" [3]=> string(3) "xxl" [4]=> string(3) "xxl" [5]=> string(3) "xxl" [6]=> string(4) "xxxl" [7]=> string(3) "xxl" [8]=> string(2) "xl" [9]=> string(4) "xxxl" [10]=> string(2) "xl" [11]=> string(3) "xxl" } ["cantidades"]=> array(12) { [0]=> string(1) "1" [1]=> string(1) "1" [2]=> string(1) "1" [3]=> string(1) "1" [4]=> string(3) "145" [5]=> string(1) "1" [6]=> string(1) "1" [7]=> string(1) "1" [8]=> string(1) "1" [9]=> string(1) "1" [10]=> string(1) "1" [11]=> string(1) "1" } ["productos"]=> array(12) { [0]=> string(3) "109" [1]=> string(3) "109" [2]=> string(3) "109" [3]=> string(3) "109" [4]=> string(3) "109" [5]=> string(3) "109" [6]=> string(3) "109" [7]=> string(3) "109" [8]=> string(3) "109" [9]=> string(3) "109" [10]=> string(3) "109" [11]=> string(3) "109" } ["equipos"]=> array(12) { [0]=> string(7) "leb oro" [1]=> string(7) "leb oro" [2]=> string(7) "leb oro" [3]=> string(7) "leb oro" [4]=> string(7) "leb oro" [5]=> string(7) "leb oro" [6]=> string(12) "es talla 4xl" [7]=> string(7) "leb oro" [8]=> string(7) "leb oro" [9]=> string(12) "es talla 4xl" [10]=> string(7) "leb oro" [11]=> string(7) "leb oro" } } 

my code page 2 (php tags ommitted):

if (!isset($_session)) { session_start(); } echo var_dump($_session['productsvalues']); 

this echo print next value:

array(8) { ["names"]=> null ["imp_nombres"]=> null ["numeros"]=> null ["imp_numeros"]=> null ["tallas"]=> null ["cantidades"]=> null ["productos"]=> null ["equipos"]=> null } 

the first level array exists, because subarrays keys printed, second level arrays null..

maybe use $_post value?? had try encode values of $_post object, saving json string instead of saving object same result, first nodes in json keys of arrays values "null"

any please?? thanks!!

you on writing values. try -

$_session['productsvalues'][] = $this->productsvalues; 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -