I would like to make a key only section of my website but the system i have currently allows you to just type in the directory (it is long as it is random strings but possible). how do i do this? i am using php, JS and html with no MySQL etc
How secret does this place have to be?
If there is no need for security then you can use JS - but anyone with a little knowledge can easily find the answer how to get inside
You can also create WordPress password protected pages and keep your secrets there
Edit the page or post you want to password protect.
In the top left corner under the Publish option Edit the visibility .
From there select Password protected and enter a password.
it needs to be quite secure as it only has to use 1 key that changes weekly but i am not going to use mysql because i do not want it stored to a database as i can manage to secure it but not too much as i want anyone who knows how to access it to be able to. plus i want to make it from scratch and do not have WP installed because i dont like wordpress so wordpress is not an option
Instead of using a MySQL database, you could also have a PHP file which contains the usernames and passwords. Or you could use the Directory Privacy option to use .htaccess rules to block access to a directory.
and how can i restrict access to a specific file/directory like google does with gmail and forcing you to log in if you go to that page
for example if you type in “https://website.domain/folder/file.html” without logging in it will just redirect you to the login page but if you are logged in it lets you get into it
To do that, either you need a session management system and check for every page if the user is logged in or not (and - possibly - check if the user is authorized to view the page). The link @Oxy sent may be useful for that.