davidcriniti Posted March 22, 2013 Share Posted March 22, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/275990-refreshing-info-within-a-session/ Share on other sites More sharing options...
Solution requinix Posted March 22, 2013 Solution Share Posted March 22, 2013 Alter the code that does the upload so that it also updates the session data. Quote Link to comment https://forums.phpfreaks.com/topic/275990-refreshing-info-within-a-session/#findComment-1420233 Share on other sites More sharing options...
davidcriniti Posted March 22, 2013 Author Share Posted March 22, 2013 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 Quote Link to comment https://forums.phpfreaks.com/topic/275990-refreshing-info-within-a-session/#findComment-1420252 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.