note 21387 added to ref.session

From: Date: Fri, 10 May 2002 20:26:20 +0000
Subject: note 21387 added to ref.session
Groups: php.notes 
Request: Send a blank email to php-notes+get-30443@lists.php.net to get a copy of this message
After having had a hard time with a provider who has --enable-trans-sid disabled, i've created this little piece of code to automatically add the session id to internal links and forms. It assumes you have the whole page loaded into $page. (Remove whitespaces from $search when copying!) $mySID = session_name().'='.session_id(); $search = array( "'(<a[^>]*href=\" (?!http://|https://|ftp://|mailto:) [^?\">]*\\?[^\">]*)\"'iU", "'(<a[^>]*href=\" (?!http://|https://|ftp://|mailto:) [^?\">]*)\"'iU", "'(<form[^>]*action=\" (?!http://|https://|ftp://|mailto:) [^?\">]*\\?[^\">]*)\"'iU", "'(<form[^>]*action=\" (?!http://|https://|ftp://|mailto:) [^?\">]*)\"'iU"); $replace = array( '\\1&'.$mySID.'"', '\\1?'.$mySID.'"', '\\1&'.$mySID.'"', '\\1?'.$mySID.'"'); $page = preg_replace($search, $replace, $page); -- http://www.php.net/manual/en/ref.session.php http://master.php.net/manage/user-notes.php?action=edit+21387 http://master.php.net/manage/user-notes.php?action=delete+21387 http://master.php.net/manage/user-notes.php?action=reject+21387

« previous php.notes (#30443) next »