Search code examples
phphtmlsessionsrc

img, empty src make influance on php working in IE?


i hate situations, when i can't explain the behavior of compiler. So help me please to understand, how it possible...

i have two php files - index.php, and admin.php. in index.php i make registration, and captcha checking, and if they are correct, i set the value of session variable to somevalue,(at first it has anothervalue) and redirect client to admin.php where the CMS is! And now, what is the problem, i have a module in admin.php which has an img element, src of which i generate when it clicked(using jquery...), but at first it has src empty

<img src="" /> and due to it, i lose the new value of session variable(it becomes anothervalue again). IT happens only in IE!!!

BUT if i set any value to src attribute, it works fine!!!

<img src="some.jpg" /> works fine

help me please to understund such behavior


Solution

  • The URI "" resolves to the current URI. So the browser tries to load the page it is currently on as an image (and all the associated PHP is run again).

    Don't set images with an empty src attribute.