in reply to
Good way to redirect to a "members only" section of website
And "hi" back, Yagna. Welcome to the Monastery.
But I'm confused. You say "I want the user to be logged into the main webpage."
Do you mean "logged into the default page (perhaps index.html -- ie, in some vernaculars, what's called the "landing"page) for the visitor initially arriving at your site, or do you mean that a successful login puts the user on a page whereon s/he can interact with the "two page application?"
My personal preference is to have the login script redirect to the ap if the uname/pw passes your tests... and, otherwise, to have it call a second CGI script which will throw up a new page which says 'That username doesn't match that password" or similar and provides a link (emphasis, LINK; NOT a redirect>) to the default (index.html or whatever).
I'm not going to bother to offer a detailed (and perhaps even rational) explanation of that preference; it's not something I've detailed -- in my own mind; let alone on paper -- to the degree needed to make it readable and defensible (which it may or may not be) :( .