PHP Session not written after Output(echo or print_r on external ajax Call) -


i´m having serious trouble debugging particular problem , hope has clue i´m doing wrong.

i have custom cms system working uses paragraphs building blocks updated using ajax(prototypejs) calls , functions parse html chunks in given order, clean them , save data in associative arrays in session variable. users log in, session created , can check session without problem in every page need it. system works directly on definitive websites, user can see updates on realtime , browse site normal user do, editing. so, nothing new here. here weird thing.

enduser site on edit mode(admin user logged in): path "/"

after logged status verified, function processes editable content , saves associative array session, starts javascript objects editing every paragraph. data saved, can use external script check if it´s there after php script ends.if load new page(new content), session gets updated new data)

admin user modifies paragraph using inplaceeditor , html chunk send via ajax php script starts named session, reads present session data, checks if paragraph should modified, appended or deleted , reassigns values existing array keys in $_session. if make var_dump() o print_r $_session after assigning new data there.after script echoes processed html, , ajax updates original paragraph on calling page.

this script in /admin/cms/...etc, means @ least 4 directories inside root of site.

when script ends, check using same session dump script see if data written/commited, no, $_session has original data calling page. same id, same session name, same session_start() no data gets written. whole operation quick, though speed problem, scripts ends before session_write_close can make work.

but if add new key $_session array , put data there, data gets updated , written. if don´t output on script , process data , set session variables get´s updated , written.

it´s members of $_session array getting blocked update.

what did track error , i´m sure i´m not doing wrong.

  • 1.- register_globals off of course
  • 2.- session_name() , session_start() present , in given
    order. used have multiple
    session_start() -close on same page
    use several named sessions, refine problem not longer so.
  • 3.- use session_write_close() after session data processed. also
    tried without, letting php decide when commit data, no luck.
  • 4.- i`m using cookies sid.
  • 5.- sessions stored on /tmp, can see data getting updated.
  • i tried using custom save handler on db, same problem,
    "_write" got called when no output present.
  • i searched php.net, stackoverflow, google, etc subject. never ask without investigation, first time in many years...but it´s unlogical must tiny haven´t thought of.

the weird thing when process data without output $_session gets updated ok. if modify script afterwards adding output , try again, instead of having new(last) value present original value back, 1 created calling page @ first place, after playing around few times! php can´t cache values between scripts or?i dont have globlals on.

i´m clueless. system worked flawless on php4.3, since i´m using 5.3.3 2 moths users caliming data getting mixed up, checked , yes, there serious problems. today updated (5.3.6) , can´t session values commited.

script code called via ajax:

<? session_cache_limiter('nocache');  session_name("cms_ses"); session_start(); include('../htmlawed/htmlawed.php'); include("utils_cms.php"); include("../../../php/utils_array.php");  $value=$_post['value']; $editorid=$_post['editorid']; $clase=$_post['clase']; $editorid=str_replace("pre","",$editorid); $value=html_entity_decode(stripslashes($value),ent_quotes); if (strlen(trim($value))==0)     {     die();     } $value="<div id=\"$editorid\"  class=\"$clase\">$value</div>";  $newxhtml=$value; $retorno=cms_nuevobloque($newxhtml,$editorid); $_session['data']['cmseditores']=$retorno[1];    $_session['data']['cmscont']=$retorno[2];    session_write_close();  print_r($retorno[0]); //offending part...without works ?> 

really nothing strange here....main page code simpler, no strange php directives, etc.

here header of caller page

include 'php/db.php'; $len=$_get['len']; $sec=$_get['sec']; $cont=$_get['cont']; $admfin=$_get['admfin']; $fecha=$_get['fecha']; $token=$_get['token']; $cur=$_get['cur'];  $php_self=$_server['php_self']; session_cache_limiter('nocache'); session_name("cms_ses"); session_start();  $passvar=''; unset($adm); if ((!empty($_session['cms_logged'])) , (!isset($admfin)) )     {     $nivelpermisos=$_session['cms_logged_group'];     $useractual=$_session['cms_logged'];     $adm=1;      } elseif (empty($_session['cms_logged']))     {     unset($useractual);     }     //.........rest of code   

update: did late night tests , found someting don´t understand.help please: has not sessions mysql querys. same code, instead of trying write $_session array made simple update innodb table using session_id. when output code, update executed,(i can output query string , no mysql_error() or notice) problems, checking database row doesn´t updated. letting output out if script , query commited. common thing sessions started , output made.

i restarted apache, etc(who knows) no luck. made stupid, because server side thing. changed browser firefox(using safari) , works! ok, recheck, safari, nothing works. both running side side, same issue. php server side, how can different browsers handle code different, can browser apache rollback, request not handled or call same script twice without notice(checked safaris developer console , script called once) ? can safari resubmit data silently because "thinks" ajax failed? checked headers using firebug , safaris developer tools , nothing strange whenever make ajax call safari, caller page reloads data(aka conection server...).

i don´t understand nothing.

i had similar problem (if have understood correctly). needed force session data written (for custom session driver) after scripts have finished running. shutdown function can registered should run after scripts have finished.

maybe solve (or solve) problem.

http://php.net/manual/en/function.register-shutdown-function.php


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -