Jump to content

refreshing info within a session


davidcriniti
Go to solution Solved by requinix,

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
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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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