Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    Session vars are used to preserve data between requests. AFAICT, you wish to pass data between unrelated functions during the same request. Global vars should work fine for this. If globals are not working for you, there is some glitch in your code. Either the global value is not assigned the value it should be getting, or your functions are being called out of order. Due to the nature of WP hooks, it’s not always obvious which callback is called in what order.

    Even more insidious, it could be you’ve encountered a race condition where the get a value thread takes so long that the use the value thread executes before the value can be gotten, even though the get a value process was called first. Multi-threading environments can contain nasty traps that we don’t realize because we tend to think sequentially when we code.

Viewing 1 replies (of 1 total)
  • The topic ‘Need to understand whether I should be using Session variables for PHP’ is closed to new replies.