+ $imapConnection = sqimap_login($login_username, $key, $imapServerAddress, $imapPort, 0);
+
+ $sqimap_capabilities = sqimap_capability($imapConnection);
+ sqsession_register($sqimap_capabilities, 'sqimap_capabilities');
+ $delimiter = sqimap_get_delimiter ($imapConnection);
+
+ sqimap_logout($imapConnection);
+ sqsession_register($delimiter, 'delimiter');
+
+ $username = $login_username;
+ sqsession_register ($username, 'username');
+ setcookie('key', $key, 0, $base_uri);
+ do_hook ('login_verified');
+
+}
+
+/* Set the login variables. */
+$user_is_logged_in = true;
+$just_logged_in = true;
+
+/* And register with them with the session. */
+sqsession_register ($user_is_logged_in, 'user_is_logged_in');
+sqsession_register ($just_logged_in, 'just_logged_in');
+
+/* parse the accepted content-types of the client */
+$attachment_common_types = array();
+$attachment_common_types_parsed = array();
+sqsession_register($attachment_common_types, 'attachment_common_types');
+sqsession_register($attachment_common_types_parsed, 'attachment_common_types_parsed');
+
+$debug = false;
+
+if ( sqgetGlobalVar('HTTP_ACCEPT', $http_accept, SQ_SERVER) &&
+ !isset($attachment_common_types_parsed[$http_accept]) ) {
+ attachment_common_parse($http_accept, $debug);
+}
+
+/* Complete autodetection of Javascript. */
+checkForJavascript();
+
+/* Compute the URL to forward the user to. */
+$redirect_url = $location . '/webmail.php';
+
+if ( sqgetGlobalVar('session_expired_location', $session_expired_location, SQ_SESSION) ) {
+ sqsession_unregister('session_expired_location');
+ $compose_new_win = getPref($data_dir, $username, 'compose_new_win', 0);
+ if ($compose_new_win) {
+ // do not prefix $location here because $session_expired_location is set to PHP_SELF
+ // of the last page
+ $redirect_url = $session_expired_location;
+ } elseif ( strpos($session_expired_location, 'webmail.php') === FALSE ) {
+ $redirect_url = $location.'/webmail.php?right_frame='.urldecode($session_expired_location);