marcin_koss Posted March 31, 2010 Share Posted March 31, 2010 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 Quote Link to comment https://forums.phpfreaks.com/topic/197068-how-to-make-session-value-available-right-after-setting-it/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 31, 2010 Share Posted March 31, 2010 A cookie behaves the way you mentioned, not a session. If you are in fact describing a cookie, you can always set the correct $_COOKIE variable to the same value you just put into the setcookie() statement. Quote Link to comment https://forums.phpfreaks.com/topic/197068-how-to-make-session-value-available-right-after-setting-it/#findComment-1034485 Share on other sites More sharing options...
gizmola Posted March 31, 2010 Share Posted March 31, 2010 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. Quote Link to comment https://forums.phpfreaks.com/topic/197068-how-to-make-session-value-available-right-after-setting-it/#findComment-1034490 Share on other sites More sharing options...
marcin_koss Posted March 31, 2010 Author Share Posted March 31, 2010 You guys are right, cookies behave this way not sessions. Anyway I'm using CodeIgniter for the first time for my project. I'm not in 100% understand this whole OO concept so that's where the problem is I'm doing something in wrong sequence. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/197068-how-to-make-session-value-available-right-after-setting-it/#findComment-1034496 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.