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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -