Jump to content

refreshing info within a session


davidcriniti

Recommended Posts

Hi,

 

I have a page where students in my school can update an avatar.  (my_profile.php)

 

On this page, they see their avatar nice and large in the middle of the page. However, on this page, as well as all other pages in the site, the avatar is also displayed in a smaller version on the top-right corner, according to session data.

 

	if (!empty($_SESSION['userName']) && $_SESSION['member_avatar'] != "") {
	       echo "<img src=\"images/member_avatars/" . $_SESSION['member_avatar'] .  "\"  width='40px' height='40px' alt=\"Avatar\" tyle=\"float: left; padding: 3px 3px 3px 3px;\"   /></td>";
  }
		 if (!empty($_SESSION['userName']) && $_SESSION['member_avatar'] == "") 
		  {
		   echo "<img src=\"images/member_avatars/default_avatar_50.gif\" width=\"40\" height=\"40\" alt=\"Your Avatar Here\" />";
    }

 

When the member uploads a new file, the large version can be seen immediately on the my_profile.php page where the code is echoing  the row in the database.

 


    echo "<img src=\"images/member_avatars/" . $my_profile["member_avatar"] . "\" height='250' width='250' alt=\"Avatar\" /></td>";

 

 

 

However, the aforementioned smaller avatar  (  $_Session['member_avatar']  )  does not update on this or any other page on the site. To update this, the user has to log out, and then log in again.

 

How can I fresh the $_Session['member_avatar'] as soon as the new image is uploaded?

 

Thanks in advance,

Dave

 

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/275990-refreshing-info-within-a-session/
Share on other sites

Thanks,

 

I fiddled around with the my_profile_updateinformation.php page, which processes the avatar upload, and inserted the following code:

 

	////Reset session
		$sql="SELECT * FROM members WHERE member_id=" . $_SESSION['member_id'] ;
$result=mysql_query($sql);
$row = mysql_fetch_array( $result );
		$_SESSION['member_avatar'] = $row['member_avatar'];

 

which seemed to do the trick. Thanks Requinix.

 

Cheers,

Dave

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.