I'd need to debug this on the live server in order to determine what is going wrong. It looks correct to me, but there is a lot to miss if I'm just looking in the code of the include file. The issue could be with the server settings, the login page, the database, the restricted page, or somewhere else I'm not thinking of. There is no way to tell without a URL to view the issue and FTP access to see and edit the code on the live site for debugging.