Unable to display image!?

Hi guys,
I have been trying to get my comment system to show user images on submit…

This is the code i’m using -

$url = "../".$_SESSION['avatar']."";
		
		return '
		
			<div class="comment">
				<div class="avatar">
					<img src="'.$url.'" />
				</div>
				
				<div class="name">'.$d['name'].'</div>
				<div class="date" title="Added at '.date('H:i \\o\
 d M Y',$d['dt']).'">'.date('d M Y',$d['dt']).'</div>
				<p>'.$d['body'].'</p>
			</div>
		';
	}

This works perfectly but the image doesn’t display on submit. However it displays when the page is refreshed…

In the image src all that is currently display before the page is refreshed is “…/” but not the full link?

It would be nice if i could echo the variable “$url” and it would work but i don’t how know if that is possible in the return function.

Can anyone please help me with this?

Without more context or an example there’s not much here to work on so here’s my assumption of what might be going on:

Session content is sent in page headers, if your headers aren’t being resent (like say this is included dynamically) you probably won’t see your updated session information. Refreshing the page would reinitialize the sending of the headers.

Check if the session variable avatar is_empty and then if it returns true use the variable that fills it instead and it might work. You can do this because you’ve already verified that it is getting populated just not in time for your return call.