Jump to content

Recommended Posts

Hi,

 

Say I've got a php page a.php, and in it I have the session start and validate that it is an authorized user etc.. and in a.php I have a form which posts to b.php. In b.php do I need to have the session things again? b.php will use the data from a.php to do processing, and I'm using all the isset($_POST[..]), if its not set it means that an unauthorized person tried to access b.php right?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/64988-is-_post-secure/
Share on other sites

Also to extend the idea about security, u could send the encrypted user's password and id to a session variable and in each page which needs authorization u can compare those values with the db ones.

 

set the session

$id = $row['id'];
$pass = $row['pass'];
$sess = $id . "." . $pass;
$_SESSION['user'] = $sess;

 

validate the session

if(isset($_SESSION['user'])){
     $sessVal = explode('.', $_SESSION['user']);
     $query = mysql_query("SELECT * FROM users WHERE id='{$sessVal[0]}' AND pass='{$sessVal[1]}'");
     $nrRows = mysql_num_rows($query);
     if($nrRows == 1){
            //code
     } else{
           die('no access here');
     }
}

Link to comment
https://forums.phpfreaks.com/topic/64988-is-_post-secure/#findComment-324351
Share on other sites

Someone could easily make a script to post to b.php.

Why not just check the referrer?

if ($_SERVER['HTTP_REFERER'] !== $_SERVER['HTTP_HOST']){
echo 'Please do not use proxies.'; }

 

I would also suggest that you encrypt sessions, because they could upload a php script to view/edit sessions(I had that happen to me before), but that's if you want strict security(and also get stronger/anonymous passwords).

 

Link to comment
https://forums.phpfreaks.com/topic/64988-is-_post-secure/#findComment-324406
Share on other sites

Its just that I'm writing a site where there are 3 types of users:

 

public, owner, and admin.

 

And for each of them they can fill in a form which allows them to access the database to extract info, depending on the type of user, they may not have access to some of the tables. So essentially I've got 3 copies of the same code, and I was just wondering if I can just use 1 copy instead since things are being posted anyway..

 

Thats alright I'll just copy and past everything. Just makes maintainence a bit difficult lol..

 

 

Link to comment
https://forums.phpfreaks.com/topic/64988-is-_post-secure/#findComment-324409
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.