Jump to content

Recommended Posts

I thought I had this beat months ago, but when I set up my stuff on a new server the problem is back and I have no clue how I beat it last time.

 

Back then, when I logged out, I could use the back button and go right back into the "secured" pages. THAT is fixed, but the username and password are still showing in the address bar:

http://www.mydomain.com/secure/data.php?SECemailpass=&SECloginusername=admin&SECloginpassword=Th3PassW0rd&SEClogin=Login

I know one person that helped then told me it was the difference between "Get" and "Post", but I'm not sure I even remember that as correct. I don't remember if that solved the "back button" issue or the URL issue. At this time, if I log out, I cannot go back and view pages (I go back to log in).

 

So, how do I fix the user/pass showing in the Address bar and being part of the history file?

 

I THINK I'm posting the relevant portion of my log-in code:

 
  <input type='hidden' id='SECemailpass' name='SECemailpass' value=''>

  <center>

  <table style='font:10pt arial;'>

    <tr>

      <td>Username:  </td>

      <td><input type='text' name='SECloginusername' value='<?php echo $_REQUEST['SECloginusername']; ?>'></td>

    </tr><tr>

      <td>Password:  </td>

      <td><input type='password' name='SECloginpassword' value='<?php echo $_REQUEST['SECloginpassword']; ?>'>

        <span style='font-size:8pt'>

        <a href='javascript:SECEmailPassword();'>Forgot your password?</a>

        </span>

      </td>

    </tr><tr>

      <td></td>

      <td align='center'><input type='submit' name='SEClogin' value='Login'></td>

    </tr>

  </table>

Link to comment
https://forums.phpfreaks.com/topic/85954-solved-user-pass-showing-in-url/
Share on other sites

Papaface: This was written for me 2-3 years ago by a programmer... I have no idea. I was told that it was the function of the way the form was done. I'm really weak in PHP.

 

Tinker, Sorry, I thought I'd done that.

  <form id='SECloginform' name='SECloginform' method='get' action='<?php echo basename($PHP_SELF); ?>'>

 

It appears its using "get"

Change this:

  <form id='SECloginform' name='SECloginform' method='get' action='<?php echo basename($PHP_SELF); ?>'>

to

  <form id='SECloginform' name='SECloginform' method='POST' action='<?php echo basename($PHP_SELF); ?>'>

and since it seem's your using $_REQUEST['*'] statements you should be ok, if not then you may need to change the appropiate $_GET['*'] statements to $_POST['*'] or to be sure $_REQUEST['']...

 

Halfway down this page there's some information on the subject.

Adam & Tinker. Thanks. I changed the "get" to "POST" and all appears well.  The script does do authentification and uses a MySQL backend to track log-ins, etc. It's really a pretty nice piece of code...for the most part.

 

Anyhow, Am I correct in thinking that this issue on logging in (and seeing/not seeing the stuff in the address bar) has nothing to do with logging out and being able to "go back" to a viewable page or log in page as described above?

I just didn't want it to be so easy (like jumping into history) to be able to log in.

 

Using https for what we're doing is probably overkill.

 

So, now I'm noticing that the LOG OUT thing I thought I had beat, isn't. Before, I thought just days ago (NOW what did I break!??!?!), when I hit the logout link, and went BACK (browser button) I went back to the log in page. Now I get a "this page displaying post data" warning and I'm back in my secure page.

 

Sigh  ???

 

This code is further down in that code for when you hit the log out link. Is this helpful to troubleshoot that?

...}

function SECShowLogoutLink() {

  global $SEClogoutstyle;

  echo "<a style='$SEClogoutstyle' href='".basename($PHP_SELF)."?SEClogout=1'>logout</a>";

}...

That's because it used POST data to send the info, so if you go BACK, then it tries to post it again.

 

So on the logout page, do a header re-direct out of it, so if they hit BACK, it just brings them back to the logout again.

Your browser stores the POST information, I bet if you go back even the form fields are still filled in! Different issue, only way around is to generate an id when you generate every page and then only allow that id to be processed once, but if you say https is too much then this protocols will be for sure!

In a php file where we hold some variables, I have this:

//
// Modify the URL to point to the logout page. This must be a complete URL.
// This is the page at which you'll be dumped after logging out.
$SECdumpurl = "http://www.ThePageToGoTo.com/";

 

then later in that page, we have this:

//***************************************************************************//

// Log out user.

//***************************************************************************//

//

if ($_REQUEST['SEClogout']==1) {

  $_SESSION = array(); // delete all session vars

  header("Location: $SECdumpurl");

}

Revraz... (Newbie here) not so much that I'm new to PHP, as I AM, but I'm always more on the "creative" side and get stuck occasionally fixing stuff I probably shouldn't be allowed to see.  ;D

 

That's to say, How would I do that??? Can I do that within that code snippet above?

This would probably be easier, assuming you have session_start(); already at the top of the page where this is

 

//***************************************************************************//

// Log out user.

//***************************************************************************//

//

if ($_REQUEST['SEClogout']==1) {

  session_destroy();
  header("Location: $SECdumpurl");

}

whether the session is destroyed or the page redirected, if I was to use the history list and jump back to appropriate page and send it off i'd still get in. However this is only really an issue in a public (cafe / work / uni) place, but if you close down the browser (with clear history option enabled) then your good to go...

That stuff seems to defeat IE pretty easily, but FFox is still able to "go back" and reload the page. Here's what I have now:

// Log out user.
//***************************************************************************//
//

if ($_REQUEST['SEClogout']==1) {

session_destroy();
unset($password);
unset($username);

  header("Location: $SECdumpurl");

}

 

When in FireFox, I can still use my browser to GO BACK, I okay the postdata warning and the "secure" page still loads

 

trie that

<?php

/* set the cache limiter to 'private' */

session_cache_limiter('private');
$cache_limiter = session_cache_limiter();

/* set the cache expire to 1 minutes */
session_cache_expire(1);
$cache_expire = session_cache_expire();

/* start the session */

session_start();

if ($_REQUEST['SEClogout']==1) {

session_destroy();


  header("Location: $SECdumpurl");

}
?>

 

BTW, this is what my session_start is at the moment...

//***************************************************************************//
$SECactive = true;
session_start();
//***************************************************************************//

 

I assume the first couple lines of your solution would replace my second actual "session_start():" line

session_cache_expire() returns the current setting of session.cache_expire.

 

The cache expire is reset to the default value of 180 stored in session.cache_limiter at request startup time. Thus, you need to call session_cache_expire() for every request (and before session_start() is called).

 

 

url

http://uk3.php.net/manual/en/function.session-cache-expire.php

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.