Saturday, 15 September 2012

javascript - getJSON and OAuth Token -



javascript - getJSON and OAuth Token -

i'm working on script uses jquery (getjson) pullback values php page. php page correctly displays encoded object right keys , values, values beingness retrieved $_session variable. when javascript attempts access page, object retrieved, keys intact values beingness replaced null. values returning null retrieved $_session, whereas values manually added correctly returning. can avoided/fixed? create more sense store access tokens in cookies rather sessions?

code examples:

<?php session_start(); $token = $_session['token'] -> access_token; $information = [ "media_token" => $token, "test" => "testing" ]; print json_encode($information); //when page straight accessed, //returns right info ?>

javascript:

$.getjson('oauth.php', function (data){ console.log(data); // media_token: null // test: testing });

turns out issue was accessing page contained js using non-www page, whereas adding www fixed problem. not sure why changed if page access $_session or not. if explain why case that'd great, cheers.

javascript php jquery oauth getjson

No comments:

Post a Comment