I'm developing a Facebook app that will run in canvas. This is the scenario (I think it's very common). This is all server-side implementation.
Being:
APP_URL: https://apps.facebook.com/xxxxxx/
CANVAS_URL: https://myexample.com/facebookApp/
Step 1 (index of the app) has a form. It has
action="CANVAS_URL/step2"
(note that is not the app Url). In order to usesigned_request
in the next step, it has an hidden field<input type="hidden" name="signed_request" value="<?php echo $_POST['signed_request'] ?>" />
Step 2: it receives the info of the form and stores it in a
Session
, then parses the signed_request. This works OK. I store it in the Session because I want to save it to a database after the user is authenticated. If user was logged on to the app, I redirect him toAPP_URL/step3
; if not, I redirect him to login dialog, with&redirect_uri=APP_URL/step3
. In both cases, note that the step 3 isAPP_URL/step3
(as I needsigned_request
again to check if user has authenticated and another data). All redirections are made with JavaScript:<script type="text/javascript">window.top.location = "URL";</script>
Step 3: now I want to save the data previously stored in the Session. BUT as the user is navigating through FB canvas, the session data is not available.
I tried several combinations. If the form is sent to APP_URL/step2
(instead of CANVAS_URL/step2
, in order to create the session for APP_URL
), I can't retrieve the posted data (because it is sent to FB, not to the CANVAS_URL
).
I thought about using the session_id
to recreate the Session in APP_URL
, but I'm afraid that it isn't a very secure approach. I'm sure that there must be a better workaround.