- global $session_expired_location, $session_expired_post;
- if (isset($session_expired_location) && $session_expired_location) {
- $compose_new_win = getPref($data_dir, $username, 'compose_new_win', 0);
- if ($compose_new_win) {
- $redirect_url = $session_expired_location;
- } else {
- $redirect_url = 'webmail.php?right_frame='.urldecode($session_expired_location);
- }
- sqsession_unregister('session_expired_location');
- unset($session_expired_location);
- if (is_array($compose_messages)) {
- sqsession_register('compose_messages');
- }
- } else {
-/* need to be adapted to compose_messages.
- if (is_array($attachments)) {
- $hashed_attachment_dir = getHashedDir($username, $attachment_dir);
- foreach ($attachments as $attachment) {
- $attached_file = $hashed_attachment_dir.'/'.$attachment['localfilename'];
- if (file_exists($attached_file)) {
- unlink($attached_file);
- }
- }
- removePref($data_dir, $username, 'attachments');
- }
-*/
- $redirect_url = 'webmail.php';
+$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);