When do Symfony's user attributes get written to session?

Posted by Rob Wilkerson on Stack Overflow See other posts from Stack Overflow or by Rob Wilkerson
Published on 2010-06-16T14:16:29Z Indexed on 2010/06/16 17:02 UTC
Read the original article Hit count: 199

Filed under:

I have a Symfony app that populates the "widgets" of a portal application and I'm noticing something (that seems) odd. The portal app has iframes that make calls to the Symfony app. On each of those calls, a random user key is passed on the query string. The Symfony app stores that key its session using myUser->setAttribute(). If the incoming value is different from what it has in session, it overwrites the session value.

In pseudo-code (and applying a synchronous nature for clarity even though it may not exist):

# Widget request arrives with ?foo=bar
if the user attribute 'foo' does not equal 'bar'
  overwrite the user attribute 'foo' with 'bar'
end

What I'm noticing is that, on a portal page with multiple widgets (read: multiple requests coming in more or less simultaneously) where the value needs to be overwritten, each request is trying to overwrite. Is this a timing problem? When I look at the log prints, I'd expect the first request that arrives to overwrite and subsequent requests to see that the user attribute they received matches what was just put into cache by the initial request.

In this scenario, it could be that subsequent requests begin (and are checked) even before the first one--the one that should overwrite the cached value--has completely finished. Are session values not really available to subsequent requests until one request has completed entirely or could there be something else that I'm missing?

Thanks.

© Stack Overflow or respective owner

Related posts about symfony