Jump to content

how to go from php to html without losing login


Recommended Posts

Hi everyone - I am trying to figure out how I can allow my logged in users to leave a php page and go to an html page without losing them as "currently logged in" - I have a site that is mixed with html and php pages and this is what I am needing: i have a user, they are logged in and are visiting a php page. then they want to go to another page(only logged in users can access the php page) - so they click on the html page they want to go to, great! - but then they want to visit another page that is a php page and requires them to be logged in in order to access it. How can i accomplish this without having them log in yet again? is this possible? i am using sessions.

Link to comment
Share on other sites

I failed to mention that if you have admin privileges you can create rewrite rules that protect the directory containing member only pages. But that is not a pure PHP solution but rather an httpd configuration solution.

Edited by gw1500se
Link to comment
Share on other sites

First of all, PHP and HTML are two separate things altogether.  PHP is typically used to generate HTML.  No matter what language you use, when you load a page in a web browser it's source will be pure HTML (and/or even JavaScript).

In PHP, the way to preserve a session on every page is to call this function before the first time that you use any $_SESSION variable or anything session related.


There's no "html page" or "php page".  There is just a file that a browser reads the best it can depending how the server reads the extension of the file.  So, in order to accomplish the problem of "keep my users logged in on an html page", you need to have PHP file that checks for the session's existence and resumes it if it exists.  If it doesn't exist, then it starts one.   Correct me if I'm wrong, but I get the feeling when you refer to a "php page", you're referring to the extension of the file ..?

mypage.html vs mypage.php


Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.