--- lib/Mail/Webmail/Gmail.pm	2005-06-22 22:35:10.000000000 +0100
+++ /usr/local/share/perl/5.8.4/Mail/Webmail/Gmail.pm	2005-12-17 17:27:25.633639568 +0000
@@ -19,7 +19,7 @@
 our $USER_AGENT = "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4";
 our $MAIL_URL = "http://mail.google.com/mail";
 our $SSL_MAIL_URL = "https://mail.google.com/mail";
-our $LOGIN_URL = "https://www.google.com/accounts/ServiceLoginBoxAuth?rm=false&service=mail&continue=http://mail.google.com/mail/";
+our $LOGIN_URL = "https://mail.google.com/accounts/ServiceLoginAuth?rm=false&continue=http://mail.google.com/mail/&PersistentCookie=yes";
 
 our %FOLDERS = (
     'INBOX'   => '^I',
@@ -96,10 +96,12 @@
     $req->content( 'Email=' . $self->{_username} . '&Passwd=' . $self->{_password} . '&null=Sign+in' );
     my $res = $self->{_ua}->request( $req );
 
-    if ( $res->is_success() ) {
+    if ( $res->is_success() or $res->is_redirect() ) {
         update_tokens( $self, $res );
-        if ( $res->content() =~ /top.location = "(.*?)";/ ) {
-            $req = HTTP::Request->new( GET => "https://www.google.com/accounts/$1" );
+        my $location = $res->header('Location');
+        if ( $location or $res->content() =~ /var url = "(.*?)";/ ) {
+            $location = "https://www.google.com/accounts/$1" unless $location;
+            $req = HTTP::Request->new( GET => $location );
             $req->header( 'Cookie' => $self->{_cookie} );
             $res = $self->{_ua}->request( $req );
             if ( $res->content() =~ /location.replace\("(.*?)"\)/ ) {
