php - Set Session Ajax Post -


anyway set session when remote login ajax .

this code

var result = null; var scripturl = "http://www.site.com/login.bs";     $.ajax({       url: scripturl,      type: 'post',      data: ({txttitle : 'tt1', txttext : 'tt2'}),      datatype: 'json',     async: false,     success: function(data) {             alert("success");         },         error: function (err) {             alert("error");          }       }); 

in target page when login session[user] set . when refresh page alert error .

target code

if($_post[txttitle]=='tt1' && $_post[txttext]=='tt2')  {      $_session[user]='ok'; } 

on backend, javascript expecting sort of json response. datatype: 'json'

try:

header('content-type: application/json'); echo json_encode(array()); 

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -