[DISCLAIMER] Since I've been getting so many comments from people about this being 'bad practice', I'm just going to say this: It IS bad practice to do it this way, but we don't know what the original poster is intending to do. For all we know, he's done everything else 100% correct and secure, and was just asking if there was a way to get at it from javascript. What I have done below is provided my best idea for how to accomplish what he has asked. [/DISCLAIMER]
You can have your php, or whatever backend language you're using, set a cookie that you can then read with javascript.
document.cookie
simple as that. You'll have to search the cookie string for the name of your logged in cookie.
You can also use that to set a cookie and do your logging in through javascript (though probably not the best idea.)
See here for a quick overview of javascript cookie access.
[edit]
To address the issue of a client script having access to session information, and the possible use of ajax suggested in the original question:
Yes, an ajax call would be a very easy way to check this. I'm more of a jQuery guy, so my ajax experience lies there, but basically, you'd do an ajax call to your backend function, and that backend function just checks the 'loggedin' session variable, returning a true or false.
Also, since you now mentioned that you're using jQuery, see this page for easy jQuery cookie access.
[/edit]