Jump to content

php session variable html not rendering


sicklermd

Recommended Posts

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?

Link to comment
Share on other sites

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.   

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.