473,505 Members | 13,807 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using SESSION in PHP

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?

thanks very much,
John
<td>User Name:</td><td align="left"><input type="text" name="username"
size="29" maxlength="30" value=""></td></tr>

<td>User Password:</td><td align="left"><input type="password"
name="userpass" size="29" maxlength="30" value=""></td></tr>
Jan 7 '08 #1
5 1543
On Jan 6, 11:36 pm, 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?

thanks very much,
John

<td>User Name:</td><td align="left"><input type="text" name="username"
size="29" maxlength="30" value=""></td></tr>

<td>User Password:</td><td align="left"><input type="password"
name="userpass" size="29" maxlength="30" value=""></td></tr>
iirc you would need to either save the plaintext password as either a
cookie or in the session that is newly created and do a callback
check.

It would be very bad to store it in either case as plaintext IMO.
Jan 7 '08 #2
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 ---
<td>User Password:</td><td align="left"><input type="password"
name="userpass" size="29" maxlength="30" value="<?php echo
$_SESSION['password']; ?>"></td></tr>
--- 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
Jan 7 '08 #3
On Jan 6, 9:43 pm, "J.O. Aho" <u...@example.netwrote:
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 ---
<td>User Password:</td><td align="left"><input type="password"
name="userpass" size="29" maxlength="30" value="<?php echo
$_SESSION['password']; ?>"></td></tr>
--- 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...
Jan 7 '08 #4
jc***@lycos.com wrote:
On Jan 6, 9:43 pm, "J.O. Aho" <u...@example.netwrote:
>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 ---
<td>User Password:</td><td align="left"><input type="password"
name="userpass" size="29" maxlength="30" value="<?php echo
$_SESSION['password']; ?>"></td></tr>
--- 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 ...
<input type=text name="userid" value="<?php echo $userid;?>">
<input type=password name="password" value="<php echo $password;?>">
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.
js*******@attglobal.net
==================

Jan 7 '08 #5
On 7 Jan, 04:36, 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?

thanks very much,
John

<td>User Name:</td><td align="left"><input type="text" name="username"
size="29" maxlength="30" value=""></td></tr>

<td>User Password:</td><td align="left"><input type="password"
name="userpass" size="29" maxlength="30" value=""></td></tr>
All bets are off when it comes to the browsers 'back' button. Even if
you've got all the caching correct, both MSIE and Firefox (and
possibly many other browsers too) maintain a two+ tier cache - if the
delay is short enough, the browser will use a cached copy of the page
REGARDLESS of the caching information sent with the page when the back
button is pressed.

You should seperate the authentication and action - either use one of
the standard HTTP authentication schemes (but not BASIC unless its
over SSL) or have a sperate login page to create a session.

C.
Jan 7 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4427
by: Jon Dellaria | last post by:
I have been using MySql as the database using JSP's and JavaBeans but recently I have wanted to start using the database connection pooling mechanism built into TomCat. I think I am having a...
5
2432
by: Abhilash.k.m | last post by:
This is regarding the session management using Out of proc session management(SQL SERVER). Among the samples below which one is better to set the session? 1. There are 20 session...
9
2364
by: Greg Linwood | last post by:
I'm having difficulty understanding Session state in ASP.Net. It's almost embarrassing asking this as I've been using ASP since it was first released & it really shouldn't be this hard to use -...
1
6391
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
5
4827
by: Åženol Akbulak | last post by:
Hello; I use in my web application FormsAuthentication. Also I use Session state (InProc). When a user logged in, I can read Session parameters. (For example Session). Problem is that, when...
13
1732
by: | last post by:
Simple question, I think... I'm storing an object in the Session object. In the code behind I read that object: trx = CType(Session("Transaction"), BOCSTransaction) If I change any...
5
8686
by: John Scott | last post by:
Ok..this a rather odd question/problem. I haven't really found a straight forward answer to how to handle this scenario, so I hope someone here can help. Here it is: I have an application...
2
2660
by: satisharas | last post by:
Hello, I am trying to write a custom session manager in ASP.NET 2.0 using oracle as the backend. I want to know how the session expires in web garden and we are using NLB (a session can be...
9
1522
by: viz | last post by:
hi, i have written a class for session handling, and i want to use it to keep track of the user. After authenticating the user in login page i am storing the session info like uname etc.. in a...
0
1585
by: srinivas srinivas | last post by:
Hi, I am developing simple peer-peer RTC application for monitoring the SDP packets and i need to set the TLS security for the transport. But iam struggling to achieving this. Iam using IP...
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4698
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1526
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.