Re: Session and validation

From: Date: Sat, 30 Oct 2004 07:57:34 +0000
Subject: Re: Session and validation
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-200701@lists.php.net to get a copy of this message
Maybe that is my problem , that session variables will get blown away when the validations are run in the same page. Shouldn't be right ?
A session variable will last the lifetime of the session... it's a php.ini setting. Session variables should remain in the session store until it is collected by the garbage collector.
Let me ask though if I setup just a validation page, then on success I'm still doing a redirect (cause it's a multi page form)
Not sure what the question was here?
Or if I validate on the next page and there is an error, I redirect back, but then I also have to consider how the error is going to get printed on the first page.
You can store an error message in a session variable. On the first page do your error output like you normally would, just check this session variable to see if there's an error. In addition to this, you can put some javascript on the first page to validate on the client's side. You shouldn't rely on this, but it can cut down on trips to the server with bad input.
Anyone ? Stuart


« previous php.general (#200701) next »