+/**
+ * Regenerate session id to make sure that authenticated session uses
+ * different ID than one used before user authenticated. This is a
+ * countermeasure against session fixation attacks.
+ * NB: session_regenerate_id() was added in PHP 4.3.2 (and new session
+ * cookie is only sent out in this call as of PHP 4.3.3), but PHP 4
+ * is not vulnerable to session fixation problems in SquirrelMail
+ * because it prioritizes $base_uri subdirectory cookies differently
+ * than PHP 5, which is otherwise vulnerable. If we really want to,
+ * we could define our own session_regenerate_id() when one does not
+ * exist, but there seems to be no reason to do so.
+ */
+sqsession_is_active();
+if (function_exists('session_regenerate_id')) {
+ session_regenerate_id();
+}
+
+/**
+* The cookie part. session_start and session_regenerate_session normally set
+* their own cookie. SquirrelMail sets another cookie which overwites the
+* php cookies. The sqsetcookie function sets the cookie by using the header
+* function which gives us full control how the cookie is set. We do that
+* to add the HttpOnly cookie attribute which blocks javascript access on
+* IE6 SP1.
+*/
+sqsetcookie(session_name(),session_id(),false,$base_uri);
+sqsetcookie('key', $key, false, $base_uri);
+
+sqsession_register($onetimepad, 'onetimepad');
+
+$sqimap_capabilities = sqimap_capability($imapConnection);
+
+/* Server side sorting control */
+if (isset($sqimap_capabilities['SORT']) && $sqimap_capabilities['SORT'] == true &&
+ isset($disable_server_sort) && $disable_server_sort) {
+ unset($sqimap_capabilities['SORT']);
+}