sicklermd Posted October 1, 2018 Share Posted October 1, 2018 (edited) i have a couple test functions that i set up to make this easier to explain. function setmsg() does just that, sets a message in a session variable. fuction viewmsg() is called on the redirected page and displays the message and then unsets the variable. the message shows up just fine, but when i view the source of the page, the html is not there. make sense? function setmsg(){ //set message to user to display $_SESSION['type'] = "noError"; $_SESSION['userMsg'] = "client status changed"; redirect("second.php"); exit; } function viewmsg() { echo '<div id="'.$_SESSION['type'].'">'.$_SESSION['userMsg'].'</div>'; unset($_SESSION['userMsg']); } view the source of the "second.php" page and this is what i get..... <div id="noError"></div> the mesage "Client status was changed" clearly displays just fine. is this normal? Edited October 1, 2018 by requinix fixed highlighting Quote Link to comment https://forums.phpfreaks.com/topic/307744-php-session-variable-html-not-rendering/ Share on other sites More sharing options...
benanamen Posted October 1, 2018 Share Posted October 1, 2018 (edited) Problem is single quotes vs double quotes. $_SESSION['type'] is echo'd with single quotes and therefore will not interpolate the variable. Edited October 1, 2018 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/307744-php-session-variable-html-not-rendering/#findComment-1561227 Share on other sites More sharing options...
requinix Posted October 1, 2018 Share Posted October 1, 2018 1 minute ago, benanamen said: problem is single quotes vs double quotes. Nope. Try again. Quote Link to comment https://forums.phpfreaks.com/topic/307744-php-session-variable-html-not-rendering/#findComment-1561228 Share on other sites More sharing options...
benanamen Posted October 1, 2018 Share Posted October 1, 2018 (edited) I think I misread the post. The redirect is obviously not right, but what html is not showing up? You mean your not seeing the usrMsg in the source? You have already unset the variable so it's not going to be in the source. Edited October 1, 2018 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/307744-php-session-variable-html-not-rendering/#findComment-1561231 Share on other sites More sharing options...
requinix Posted October 1, 2018 Share Posted October 1, 2018 The stuff inside the <div> from the "userMsg". The "type" is still working fine. Quote Link to comment https://forums.phpfreaks.com/topic/307744-php-session-variable-html-not-rendering/#findComment-1561233 Share on other sites More sharing options...
benanamen Posted October 1, 2018 Share Posted October 1, 2018 (edited) Yeah, I finally figured out what the op was trying to say. Post was not worded very well. I edited my post as you were posting. Edited October 1, 2018 by benanamen Quote Link to comment https://forums.phpfreaks.com/topic/307744-php-session-variable-html-not-rendering/#findComment-1561234 Share on other sites More sharing options...
requinix Posted October 1, 2018 Share Posted October 1, 2018 I fixed the highlighting so it should look better. Should show that there's no interpolation happening. Quote Link to comment https://forums.phpfreaks.com/topic/307744-php-session-variable-html-not-rendering/#findComment-1561235 Share on other sites More sharing options...
sicklermd Posted October 1, 2018 Author Share Posted October 1, 2018 i'm not sure i understand, change my single quotes to double? if i unset the $_session['type'] after echoing it, it has the same issue. it will be visible on the screen, but gone when you view source. also the redirect is another function, sorry i didn't say that. Quote Link to comment https://forums.phpfreaks.com/topic/307744-php-session-variable-html-not-rendering/#findComment-1561241 Share on other sites More sharing options...
requinix Posted October 1, 2018 Share Posted October 1, 2018 When you're pulling up the source for the page, the browser is requesting the page a second time. It's not showing you the original source that it was presenting. If you just want to browse the markup and don't mind seeing the current state of the DOM (as opposed to the original markup that the server returned) then use your browser's Inspect feature, whatever it may be called. Quote Link to comment https://forums.phpfreaks.com/topic/307744-php-session-variable-html-not-rendering/#findComment-1561250 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.