in reply to login to a secure web site via JavaScript

There are two fundamental problems.

1. Use of credentials method is wrong - this is for HTTP authentication, but archives.newyorker.com authenticates via Web form.

2. Your idea of what constitutes a session is different from the Web site. The User-Agent header clearly is not enough; most sites would carry a session in cookies. You would need to load Safari cookies into HTTP::Cookies::Safari and then feed that into LWP::UserAgent.

If that doesn't work (which is likely, since LWP has not kept up at all with Web APIs in current use), try WWW::Scripter or WWW::Mechanize::Chrome instead.