jquery - PHP Sessions lost on ajax call -
i giving users option login via facebook, fine except wish move other pre-set session variables through last page of app. sessions declared on facebook login page. facebook login button uses axjax/jquery load php page in background. php background page cannot grab session variables login page. pretty stuck on days. can please assist?
code below runs when login button clicked in frame on login page session variables set. expected having session_start() work not. echoed vars did not print.
//facebook login page if(isset($_get["logout"]) && $_get["logout"]==1) { //user clicked logout button, distroying session variables. session_destroy(); header('location: '.$return_url); } ?> <?php session_start(); if(!isset($_session['logged_in'])) { echo '<div id="results">'; echo '</div>'; echo '<a href=" " rel="nofollow" class="fblogin-button" onclick="javascript:callafterlogin();return false;"> </a>'; } else { echo 'hi '. $_session['user_name'].'! logged in via facebook, <a href="? logout=1">log out</a>.'; } ?> <div id="fb-root"></div> <script type="text/javascript"> window.fbasyncinit = function() { fb.init({ appid: '<?php echo $appid; ?>', cookie: true,xfbml: true, channelurl: '<?php echo $return_url; ? >/concrete/blocks/external_form/forms/channel.php', oauth: true }); }; (function() { var e = document.createelement('script'); e.async = true;e.src = document.location.protocol +'//connect.facebook.net/en_us/all.js'; document.getelementbyid('fb-root').appendchild(e);}()); function callafterlogin(){ fb.login(function(response) { if (response.status === "connected") { lodinganimate(); //animate login fb.api('/me', function(data) { if(data.email == null) { alert("login requires access email address!"); resetanimate(); }else{ ajaxresponse(); } }); } }, {scope:'<?php echo $fbpermissions; ?>'}); } //functions function ajaxresponse() { //load data server , place returned html matched element using jquery load(). $( "#results" ).load( "process_facebook.php" ); }
being didn't share code, i'm not sure problem is. however, you're saying, think should try adding top of php background page:
session_start();
Comments
Post a Comment