开发者

Can you refresh a SESSION when refreshing a page? AND HOW?

I would like开发者_C百科 to know how to refresh a page using AJAX, without having to reload it (F5, reload button, etc).

In my session (when I'm logged in), I upload and store a picture in my database. Every time I change my profile picture I have to log out and log in to view it. How can I refresh the page so it shows my new picture without having to reload the entire document?


I'm guessing your login code does something like:

$_SESSION['avatarurl'] = '/some/path/pic.jpg';

and that's the ONLY place where you set this session value. You would have to modify your "upload a new avatar" code to reset that value to the NEW url:

$_SESSION['avatarurl'] = '/some/path/newpic.jpg';

which would take effect on next page refresh, WITHOUT having to do a full logout/login cycle.

The browser will display whatever image you tell it to. If it's not changing the picture after you've uploaded a new copy, it's because you code has not made the necessary changes to tell the browser that something new is available.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜