jcage@lycos.com wrote:
> Hello,
>
> I have a form that uses a basic passphrase to ensure an employee user
> is who they say they are. One field uses 'text' as the input type and
> the other uses 'password'. When a query has been run, a user can
> click the browser back button and the name is still there intact but
> the password field is blank. My question is, what would the 'SESSION'
> code look like that would allow a user to click their back button
> where the 'userpass' field holds the original passphrase in the same
> manner the browser holds the user name within the text field?
Using Session will require that the user is logged in before the password will
be there.
--- page that gets the username/password ---
session_start();
$_SESSION['password']=$_POST['userpass']; // we assume you use default post
--- eoe ---
If you want the password to be stored between sessions, then you have to use
cookies, which means you store the password in plain text on the client computer.
I suggest you talk with the system administration and ask if it would be
possible to upgrade the browsers to a more modern one, visit mozilla.org if
you want a browser that can store both the username and password and on top of
all encrypts the password it stores.
--
//Aho
Re: Using SESSION in PHP
am 07.01.2008 12:45:01 von Jerry Stuckle
jcage@lycos.com wrote:
> On Jan 6, 9:43 pm, "J.O. Aho" wrote:
>> jc...@lycos.com wrote:
>>> Hello,
>>> I have a form that uses a basic passphrase to ensure an employee user
>>> is who they say they are. One field uses 'text' as the input type and
>>> the other uses 'password'. When a query has been run, a user can
>>> click the browser back button and the name is still there intact but
>>> the password field is blank. My question is, what would the 'SESSION'
>>> code look like that would allow a user to click their back button
>>> where the 'userpass' field holds the original passphrase in the same
>>> manner the browser holds the user name within the text field?
>> Using Session will require that the user is logged in before the password will
>> be there.
>>
>> --- page that gets the username/password ---
>> session_start();
>> $_SESSION['password']=$_POST['userpass']; // we assume you use default post
>> --- eoe ---
>>
>> --- the login form ---
>>
>> --- eoe ---
>>
>> If you want the password to be stored between sessions, then you have to use
>> cookies, which means you store the password in plain text on the client computer.
>>
>> I suggest you talk with the system administration and ask if it would be
>> possible to upgrade the browsers to a more modern one, visit mozilla.org if
>> you want a browser that can store both the username and password and on top of
>> all encrypts the password it stores.
>>
>> --
>>
>> //Aho
>
> Hmmm... Guess I'm back to looking at using cookies. :-) As I
> searched for a solution, I happened across http://www.phpfreaks.com/tutorials/120/0.php
> and tweaked some code to get it to return 'something' in the password
> field, just not what I was looking for. thanks for the replies, all...
>
That's a little old (over 4 years) and a bit out of date. You don't
need setcookie(); just use $_COOKIE.
You also don't need to store the password in plain text on the user's
machine. You could easily hash the password.
Some ideas - untested, but alter as required to suit your needs:
$userid = ''; // Initialize the values
$password = '';
$hashedpw = '';
if (isset($_COOKIE['userid'])) { // If userid is in cookie
$userid = $_COOKIE['userid']);
if (isset($_COOKIE['password'])) // Check for hashed password
$hashedpw = $_COOKIE['password'));
}
... other stuff, as necessary ...
if ($userid <> '') {
$result = mysql_query("SELECT pw, MD5(pw) AS hashedpw FROM users " .
"WHERE userid = $userid");
if ($result) {
$data = mysql_fetch_assoc($result);
if ($data) {
if (($data['hashedpw'<>'') && ($data['hashedpw']==$hashedpw))
$password = $data['password'];
}
... other stuff, as necessary ...
But this won't necessarily help you when the user uses the back button.
With the back button, your browser is probably pulling the information
from the cache. If the password was filled in by the above code (i.e.
the cookie existed and was valid) the first time the user displayed the
page, the password should be filled in the second time. But if the user
typed in the password, the password may not be filled in. This
operation is browser dependent and there isn't anything you can do about
it from the PHP end.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Using SESSION in PHP
am 07.01.2008 13:12:05 von Michael Fesser
..oO(Jerry Stuckle)
>jcage@lycos.com wrote:
>
>> Hmmm... Guess I'm back to looking at using cookies. :-) As I
>> searched for a solution, I happened across http://www.phpfreaks.com/tutorials/120/0.php
>> and tweaked some code to get it to return 'something' in the password
>> field, just not what I was looking for. thanks for the replies, all...
>>
>
>That's a little old (over 4 years) and a bit out of date. You don't
>need setcookie(); just use $_COOKIE.
Assigning a value to $_COOKIE doesn't actually send a cookie. You still
need setcookie(), especially since there might be some more parameters
required in order to control the cookie behaviour.
Micha
Re: Using SESSION in PHP
am 07.01.2008 13:12:05 von Michael Fesser
..oO(Jerry Stuckle)
>jcage@lycos.com wrote:
>
>> Hmmm... Guess I'm back to looking at using cookies. :-) As I
>> searched for a solution, I happened across http://www.phpfreaks.com/tutorials/120/0.php
>> and tweaked some code to get it to return 'something' in the password
>> field, just not what I was looking for. thanks for the replies, all...
>>
>
>That's a little old (over 4 years) and a bit out of date. You don't
>need setcookie(); just use $_COOKIE.
Assigning a value to $_COOKIE doesn't actually send a cookie. You still
need setcookie(), especially since there might be some more parameters
required in order to control the cookie behaviour.
Micha
Re: Using SESSION in PHP
am 07.01.2008 14:18:14 von Jerry Stuckle
Michael Fesser wrote:
> .oO(Jerry Stuckle)
>
>> jcage@lycos.com wrote:
>>
>>> Hmmm... Guess I'm back to looking at using cookies. :-) As I
>>> searched for a solution, I happened across http://www.phpfreaks.com/tutorials/120/0.php
>>> and tweaked some code to get it to return 'something' in the password
>>> field, just not what I was looking for. thanks for the replies, all...
>>>
>> That's a little old (over 4 years) and a bit out of date. You don't
>> need setcookie(); just use $_COOKIE.
>
> Assigning a value to $_COOKIE doesn't actually send a cookie. You still
> need setcookie(), especially since there might be some more parameters
> required in order to control the cookie behaviour.
>
> Micha
>
Good point, Micha. I should know not to post before my first cup of
coffee :-)
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Using SESSION in PHP
am 07.01.2008 14:18:14 von Jerry Stuckle
Michael Fesser wrote:
> .oO(Jerry Stuckle)
>
>> jcage@lycos.com wrote:
>>
>>> Hmmm... Guess I'm back to looking at using cookies. :-) As I
>>> searched for a solution, I happened across http://www.phpfreaks.com/tutorials/120/0.php
>>> and tweaked some code to get it to return 'something' in the password
>>> field, just not what I was looking for. thanks for the replies, all...
>>>
>> That's a little old (over 4 years) and a bit out of date. You don't
>> need setcookie(); just use $_COOKIE.
>
> Assigning a value to $_COOKIE doesn't actually send a cookie. You still
> need setcookie(), especially since there might be some more parameters
> required in order to control the cookie behaviour.
>
> Micha
>
Good point, Micha. I should know not to post before my first cup of
coffee :-)
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================