Retrieving Drupal user session from Flex3

Events happening in the community are now at Drupal community events on www.drupal.org.
redluk-gdo's picture

I've been having an issue for a week now.

I have a tiny Flex 3 app which simply retrieves the current drupal user session and displays the user data.
I'm using D6, services, amfphp with sessid turned off.

When I run the app on my laptop, the system.connect() method returns the proper Drupal user/session. If I switch user in Drupal and refresh the app I get updated and accurate user data displayed. My Sessions table only shows one Drupal session and my Flex app uses that session correctly. Seems smooth enough.

My problem is when other users access the app. Two scenarios here:
Use sessid enabled:
When system.connect() is called an anonymous sessions is created in the Sessions table regardless if there is an active Drupal logged in session in the DB. It's as if the global $user or session_id() calls can't find the right Drupal session. Thus the insertion of an anonymous session.

Use sessid disabled:
A new cookie based session is created and the app retrieves only that cookie session. Which in turn is also anonymous.

In any case, other users (non-me from my laptop) never get their correct Drupal session.

I do not want to use a new session for the app but rather use the existing (logged in, or not) Drupal session.

Am I missing something here?

Thanks for any help !

Comments

hmm...solved?

redluk-gdo's picture

When I load the app from inside a node, the sessions are properly fetched it seems. But if I run the app directly from a directory inside the Drupal structure, sessions get totally confused. I'm not sure if this was my problem, but it seems to work for now.

Any insights?

==========================

FALSE ALERT: APP IS STILL BEHAVING WEIRDLY WHEN FETCHING SESSIONS

what works for me

dsgirard's picture

is to add the following line

$_COOKIE[session_name()] = $sessid;

to function services_session_restart in services.module.

otherwise sess_read() in session.inc craps out.

I'm not a sessions expert; does anyone know if there are any side effects from this?

d

Services

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: