Index: /branches/release-38/default_templates/javascript.mtml
===================================================================
--- /branches/release-38/default_templates/javascript.mtml (revision 2375)
+++ /branches/release-38/default_templates/javascript.mtml (revision 2377)
@@ -779,5 +779,5 @@
      */
     </mt:Ignore>
-    if ( is_preview )
+    if ( is_preview && !user )
         mtFetchUser();
 }
Index: /branches/release-38/default_templates/comment_preview.mtml
===================================================================
--- /branches/release-38/default_templates/comment_preview.mtml (revision 2313)
+++ /branches/release-38/default_templates/comment_preview.mtml (revision 2377)
@@ -3,11 +3,12 @@
 <html xmlns="http://www.w3.org/1999/xhtml" id="sixapart-standard">
 <head>
-    <$mt:include module="<__trans phrase="HTML Head">"$>
-    <title><$MTBlogName encode_html="1"$>: <__trans phrase="Previewing your Comment"></title>
     <script type="text/javascript">
     /* <![CDATA[ */
+    var user = <$MTUserSessionState$>;
     var is_preview = true;
     /* ]]> */
     </script>
+    <$mt:include module="<__trans phrase="HTML Head">"$>
+    <title><$MTBlogName encode_html="1"$>: <__trans phrase="Previewing your Comment"></title>
 </head>
 <body id="<$mt:BlogTemplateSetID$>" class="mt-comment-preview <$MTVar name="page_layout"$>" onload="mtEntryOnLoad()">
Index: /branches/release-38/lib/MT/Core.pm
===================================================================
--- /branches/release-38/lib/MT/Core.pm (revision 2245)
+++ /branches/release-38/lib/MT/Core.pm (revision 2377)
@@ -535,5 +535,8 @@
             'upgrade'  => { handler => 'MT::App::Upgrade', },
             'wizard'   => { handler => 'MT::App::Wizard', },
-            'comments' => { handler => 'MT::App::Comments', },
+            'comments' => {
+                handler => 'MT::App::Comments',
+                tags => sub { MT->app->load_core_tags },
+            },
             'search'   => {
                 handler => 'MT::App::Search::Legacy', 
Index: /branches/release-38/lib/MT/Template/ContextHandlers.pm
===================================================================
--- /branches/release-38/lib/MT/Template/ContextHandlers.pm (revision 2371)
+++ /branches/release-38/lib/MT/Template/ContextHandlers.pm (revision 2377)
@@ -511,4 +511,6 @@
             SearchIncludeBlogs => sub { '' },
             SearchTemplateID => sub { 0 },
+
+            UserSessionState => sub { 'null' },
 
             BuildTemplateID => \&_hdlr_build_template_id,
Index: /branches/release-38/lib/MT/App/Comments.pm
===================================================================
--- /branches/release-38/lib/MT/App/Comments.pm (revision 2373)
+++ /branches/release-38/lib/MT/App/Comments.pm (revision 2377)
@@ -88,4 +88,12 @@
         $app->mode('generate_captcha');
     }
+}
+
+sub load_core_tags {
+    return {
+        function => {
+            UserSessionState => \&_hdlr_user_session_state,
+        },
+    };
 }
 
@@ -1430,11 +1438,8 @@
 }
 
-sub session_js {
-    my $app = shift;
-    my $blog_id = int($app->param('blog_id'));
-    my $blog = MT::Blog->load( $blog_id ) if $blog_id;
-    my $jsonp = $app->param('jsonp');
-    $jsonp = undef if $jsonp !~ m/^\w+$/;
-    return $app->error("Invalid request.") unless $jsonp;
+sub session_state {
+    my $app = shift;
+    my $blog = $app->blog;
+    my $blog_id = $blog->id if $blog;
 
     my $c;
@@ -1479,5 +1484,5 @@
 
     unless ($c) {
-        my $can_comment = $blog->allow_anon_comments ? "1" : "0";
+        my $can_comment = $blog && $blog->allow_anon_comments ? "1" : "0";
         $c = {
             is_authenticated => "0",
@@ -1490,10 +1495,29 @@
     }
 
+    return $c;
+}
+
+sub session_js {
+    my $app = shift;
+    my $jsonp = $app->param('jsonp');
+    $jsonp = undef if $jsonp !~ m/^\w+$/;
+    return $app->error("Invalid request.") unless $jsonp;
+
+    my $state = $app->session_state;
+
     require JSON;
     $app->{no_print_body} = 1;
     $app->send_http_header("text/javascript");
-    my $json = JSON::objToJson($c);
+    my $json = JSON::objToJson($state);
     $app->print("$jsonp(" . $json . ");\n");
     return undef;
+}
+
+sub _hdlr_user_session_state {
+    my ($ctx, $args, $cond) = @_;
+    my $state = MT->app->session_state();
+    require JSON;
+    my $json = JSON::objToJson($state);
+    return $json;
 }
 
@@ -1839,4 +1863,6 @@
         return undef unless $entry;
         $app->{_blog} = $entry->blog if $entry;
+    } elsif ( my $blog_id = $app->param('blog_id') ) {
+        $app->{_blog} = MT::Blog->load( int($blog_id) );
     }
     return $app->{_blog};
