How Can I Recover PHP $_SESSION variables from within Objective-C / iOS? -
i have php scripts on server return cookies, html code, etc. interact ios app have been working on. things login, send item, receive item, etc.
problem maintaining persistent connection. figured we'd use cookies, , php "start session" allow access $_session variables via cookie. however, i'm not able find of session data returned in cookie, other session id.
i thought use session id + key grab elements off php session array calling script within app. app isn't problem much:
i need know $_session variables can use them. may sound facetious, need.
if start session, like:
$_session['username']=$_get['username']
shouldn't able return variable set session using following:
$session_id = $_get['session_id']; $key = $_get['key']; function getsessionvalue($session_id, $key) { session_start($session_id); return $_session[$key]; } echo getsessionvalue($session_id, $key);
something isn't working...i appreciate , help! :d
first of all, session_start()
does not take parameter. so, stating session id there won't help.
secondly, default php use cookie store session id in variable named phpsessid
. php set variable when first access page. make sure add cookie variable (with same value php set) when making requests server.
the default storage cookies files. location of files set in session.save_path
variable in php configuration. on ubuntu, default location /var/lib/php5
when request comes phpsessid
variable set in cookie, calling session_start()
wil make php take cookie value , read coressponding session file , set $_session
variable.
Comments
Post a Comment