Jump to content

How to make session value available right after setting it?


marcin_koss

Recommended Posts

I'm working on a application that uses menu that relies on session data. Menu options change depending on what value is set in session variable. Because new session variable is always available until after next reload of a page the menu is shown incorrectly after first refresh (meaning there's no changes).

Does anybody have idea how to make it work, or maybe I should use some different approach? Any suggestions?

 

Thanks

Marcin

Link to comment
Share on other sites

Perhaps you are having an issue understanding what happens - when.  When you set a $_SESSION variable, it is available in the scope in exactly the same way that any other variable is available. 

 

It sounds like the issue may be that in your script you output some html, then perform some logic -- set the $_SESSION variable, and this does not change your already emitted html! 

 

You need to have a clear idea in your mind about how HTTP works, and how the browser works with the server. 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.