Jump to content

When Using a Login Script?


glassfish

Recommended Posts

I am looking to use this for an admin panel.

 

session_start.php

"session_start()"
"if statement" where it checks if a successful login is given

Is it necessary to include "session_start.php" into the top of each script file?

 

If I just include "session_start.php" into the top of the "main" file where the other script files are included inside of the "main" as well, then I have it in ways where the other script files could get called up through the URL.(?)

 

I thought it is a bit too much to include "session_start.php" into each script file.

 

Is there a way where this can be done with more simple ways?

 

I would appreciate the suggestions a lot.

Link to comment
Share on other sites

 

Is it necessary to include "session_start.php" into the top of each script file?

 

If I just include "session_start.php" into the top of the "main" file where the other script files are included inside of the "main" as well, then I have it in ways where the other script files could get called up through the URL.(?)

 

I thought it is a bit too much to include "session_start.php" into each script file.

 

Is there a way where this can be done with more simple ways?

 

 

 

 

I typically just have one or maybe a couple of entry points:

 

index.php

//error settings, date settings, etc...
session_start();
//based on $_GET['page'], figure out which part of script to run...
Link to comment
Share on other sites

I hope i do understand your questions.

 

First of all, includes in php are includes from the server's filesystem . That will say that you can include php files from any directory where you have enough rights to read them.

And that means that you can include the files from a place outside your public html directories. (or web-root),

 

For example if your webroot starts here: /var/www/public_html and your main index.php is here: /var/www/public_html/index.php then you could for example make a new directory in the /var/www directory and name him includes for example. in this new directory you can place your php include files like sessions.php for example.

 

The result would be this:

/var/www/includes/sessions.php

/var/www/public_html/index.php

 

inside the index.php you could include sessions.php:

include '/var/www/includes/sessions.php'; 

But sessions.php is NOT available from outside the server.

Edited by Frank_b
Link to comment
Share on other sites

You don't. What Frank_b is suggesting is putting your included scripts above the web root, where the user can't access them anyway. Anything above the /public_html/ directory (in this server set-up, sometimes it's called /www/, sometimes it's /html_docs/) is inaccessible from the internet. So, by using something like

require_once('../includes/IncludedFile.php');

from your /var/user_directory/public_html/index.php script, you'll be accessing /var/user_directory/includes/IncludedFile.php, and can use the functions or class in that script in your display file. Of course, Frank_b was recommending an absolute server path to the includes directory instead of the relative that I typed.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

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

Guest
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.