0 Replies Latest reply on Nov 25, 2009 8:11 AM by JonoB

    Sync client model with server session

    JonoB

      I have a flex app that works off an amfphp stack with a mysql backend.

      I am using the php $_SESSION superglobal to store various params. For example, one of the vars that is stored is a company_id, which maps to the id field in the company table. This var is used in almost every query.

      The same var maps to the flex model: model.company.id. If user swaps to a different company on client, then a php service is called to udpate the session variable on the server. This all works 100%

      However, there is one small issue, and thats if user opens up two browser tabs in the same browser. It seems that $_SESSION vars are per browser, and not per tab. So, user opens up Company A in tab 1, and then opens up Company B in tab 2. Server session is now set to Company B, but tab 1 doesnt know this - and it still shows all information pertaining to Company A. Big problem, because user thinks that he is getting information on Company A, when in fact all the services are retrieving information on Company B, and he has no way of knowing that.

      I am not sure of the best way around this. I could do a small service call before any other service call, and check if model.company.id == $_SESSION['company_id'] but that may be a really time consuming exercise.

      Any other ideas on the best way to get around this?