Re: Session Variable Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At 2:22 PM -0400 3/20/10, Gary wrote:
I have this perplexing issue of session varibles getting dropped.  It is a 4
page form, the last page being a review page incase the submitter wants to
change any of the information.If you go through the form, all of the
information carries forward, and from the review page if you go back to
edit, it is there, however is you go back to page 2, then to page 1, page
one info is gone.It gets worse in that page 2 sessions drop (more likely
over written) if you go from page 3 to 2.

Each page is started with

<?php if(!isset($_SESSION)) {
    session_start();
 }

Session varible:

$_SESSION['lend_fname']=stripslashes($_POST['lend_fname']);

Calling the session varible to the input field for review

<?php if (isset($_SESSION['lend_fname'])) {echo
'value="'.htmlentities($_SESSION['lend_fname']).'"';}?>

The page starts at http://www.paulgdesigns.com/one2one/lend_bor_input.php

Im confused as to why they keep getting dropped and how to stop it.

Hopefully I have given enough information.

Thank you

Gary

Gary:

I think I know what the problem is. When you revisit previous pages, you write over the previous data from an empty $_POST. Here's a way to stop that.

<?php session_start();

if (isset($_POST ['lend_fname'])
  {
  $_SESSION['lend_fname'] = $_POST['lend_fname'];
  }

As far as using strip_slashes() and htmlentities() I wait until I am going to use the variables in some manner and then clean/scrub them all at one time. That makes the process simpler for me -- plus I can then keep all my security checks in one location.

Cheers,

tedd

--
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux