Ajax reset session php -
i use own framework, in localhost works fine not on server.
i'm logged, i've session id.
on ajax request, php script doesn't keep session, if return session, session empty me in side, keep session.
it's if server thinks ajax request new user.
i don't know , can't post framework code here... yesterday have issue (at work) @ home, retested , worked great...
i don't it...
$(document).on('click', '.edit', function(){ $.ajax({ type: "post", url: root+"list", data: {id:id}, headers: { accept : "application/json; charset=utf-8" }, cache: false, success: function(data){ console.log(data.sess.role); if(data.status == "error"){ //error }else{ //ok } } }); });
controller:
public function editaction(){ //if(!$this->role('tokayn')){ $this->redirecturl('thread_index'); } if(request::post()){ if(is_int($_post['id'])){ $user = $this->batiments->findbyid($_post['id']); if($user->id_proprio == $_session['id']){ $data = array('status'=>'ok', 'message'=>$user); request::renderjson($data); }else{ request::renderjson(array('sess'=>$_session)); //$data = array('status'=>'error', 'message'=>'error'); //request::renderjson($data); } }else{ $data = array('status'=>'error', 'message'=>'error'); request::renderjson($data); } }else{ //$this->redirecturl('thread_index'); } }
if user not logged, session role 'visitor' if he's logged, session role 'connected'.
i've echo before ajax form , it's 'connected'. then, on submit ajax form, ajax request return 'visitor' if refresh, keep 'connected' echo...
i've faced issue me problem was using
https://server:1234/somecontroller
while requesting ajax
http://server:3344/somecontroller
and session not shared between https , http double check if apply you.
Comments
Post a Comment