php sessions value get wiped after ajax request -


i have script set uid , email sessions when user logs in.

in 2 variables:

$_session["uid"] = $user_id;//1,2,3 etc.. $_session["email"] = 'my@email.com'; 

i have feature user can post data via ajax. when data sent server , request completed, email session's value gets wiped , causes user not able actions.

i searched whole script , couldnt find any

$_session["email"] = ''; 

after ajax request done or wherever else might be.

any clues?

edit: var_dump of _session:

array(2) { ["email"]=> &string(0) "" ["uid"]=> &string(11) "91283921834" } 

solution: host showing 5.2.17 default php version had call

addtype application/x-httpd-php53 .php 

in .htaccess file make see 5.3.5 live php version removed references , working fine.

you somewhere assign variable reference session, can see & character in var_dump:

array(2) { ["email"]=> &string(0) "" ["uid"]=> &string(11) "91283921834" } #                     ^^^                     ^^^ 

a reference in php means, in case $_session['email'] has become alias other variable. if other variable changed, $_session['email'] change it's alias.

so not need code change $_session['email'] more importantly parts makes alias , alias changed well.

it's guess search &$email or $email. functions accept parameters reference (&$parameter), return reference or called parameters reference.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -