SpringVark Posted December 10, 2009 Share Posted December 10, 2009 Hi -- I originally posted this on the Linux forum but it may apply here too. My application reads an HTML String from the request, into a session parameter as follows: $_SESSION['post_content'] = $_REQUEST['content']; When I retrieve the value of the posted HTML on the next page <?php echo $_SESSION['post_content'] ?> my local (WAMP) environment's output differs from the the output on my hosted (Linux) environment. The hosted environment escapes all double-quotes (as I imagine the htmlspecialchars() method might do): <div class=\"c\"> but my local Windows environment does not (this is the desired behaviour): <div class="c"> Obviously this has disausterous consequences when I try to commit the markup to my DB. Is there any reason for the behaviour, and how do I stop it? I do use htmlspecialchars() before committing to the database, but not before any of the screens described above. Any help is much appreciated! Link to comment https://forums.phpfreaks.com/topic/184701-windowslinux-_session-output-inconsistency/ Share on other sites More sharing options...
mrMarcus Posted December 10, 2009 Share Posted December 10, 2009 htmlspecialchars() does not do any escaping. it converts markup to "non-threatening" special characters. you're "hosted environment" has magic quotes turned on which automatically adds a backslash to any requested data ($_GET, $_POST, $_COOKIE) that contains a single or double-quote. Link to comment https://forums.phpfreaks.com/topic/184701-windowslinux-_session-output-inconsistency/#findComment-975083 Share on other sites More sharing options...
Zyx Posted December 10, 2009 Share Posted December 10, 2009 This is called "magic quotes" and has nothing to do with the operating system and sessions. You can disable them in php.ini.: magic_quotes_gpc = Off magic_quotes_runtime = Off magic_quotes_sybase = Off Actually, magic quotes do not affect sessions, but take a look - you put to a session the data from $_REQUEST variable, where magic quotes are active. PS. Do not worry, magic quotes are deprecated since PHP 5.3 and will be removed in PHP 6.0 (finally...). Link to comment https://forums.phpfreaks.com/topic/184701-windowslinux-_session-output-inconsistency/#findComment-975085 Share on other sites More sharing options...
SpringVark Posted December 10, 2009 Author Share Posted December 10, 2009 Thanks Guys! That is seriously helpful. I am much obliged... what do you drink? Link to comment https://forums.phpfreaks.com/topic/184701-windowslinux-_session-output-inconsistency/#findComment-975089 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.