[PHP] $_SESSION variable gets lost on FORM action

2007-01-16 Thread Nuno Oliveira

Hi,

I'm working on a website and one of the features that I've implemented 
so far is the user timeout.


Every time that a user browses to a different page, the variable named 
$_SESSION['user']['lastactive'] is updated to the current time.


However, before that, my PHP scripts check if the session for this user 
had timed out or not...


The script that checks that is named session.php and it is included in 
every file. If it detects a timeout, it sets a variable 
$_SESSION['form']['errors'] to a string ('Your session has expired... 
Bla, bla, bla...') and then redirects to the login.php and the user will 
see that he his being asked to login again for the reason displayed.


Everything works great except in one situation... If the timeout period 
happens when the user is filling a form, the action that it executes 
(process.php) will also include session.php and it sets the error string 
but when it redirects to login.php the $_SESSION['form']['errors'] 
variable is empty...


Can anyone help me with this?


Thanks

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



Re: [PHP] $_SESSION variable gets lost on FORM action

2007-01-16 Thread Nuno Oliveira

David Giragosian wrote:

On 1/16/07, Nuno Oliveira [EMAIL PROTECTED] wrote:


Hi,

I'm working on a website and one of the features that I've implemented
so far is the user timeout.

Every time that a user browses to a different page, the variable named
$_SESSION['user']['lastactive'] is updated to the current time.

However, before that, my PHP scripts check if the session for this user
had timed out or not...

The script that checks that is named session.php and it is included in
every file. If it detects a timeout, it sets a variable
$_SESSION['form']['errors'] to a string ('Your session has expired...
Bla, bla, bla...') and then redirects to the login.php and the user will
see that he his being asked to login again for the reason displayed.

Everything works great except in one situation... If the timeout period
happens when the user is filling a form, the action that it executes
(process.php) will also include session.php and it sets the error string
but when it redirects to login.php the $_SESSION['form']['errors']
variable is empty...



You must be unsetting the individual $_SESSION['form']['errors']  variable
or the entire $_SESSION array somewhere in there.

David



Hi Davis, thanks for the reply.

I think that I've found the problem... But if you (or anyone else) can 
confirm I would appreciate.


Sometimes in my code I use the Header('Location: index.php?var=value'); 
and I've found out (I think) that when one of these headers are executed 
by PHP, the rest of the script gets executed.



I'm thinking that this is the problem because I've eliminated all the 
occurrences where the SESSION var was cleared until only one exists and 
it was after a Location Header.


I've put an exit(); after the header and the problem was gone... :)

Is this the correct PHP/HTML behavior or is there another problem? Am I 
supposed to put an exit(); after a header Location to make sure that 
no more code gets executed?


Thanks

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



Re: [PHP] $_SESSION variable gets lost on FORM action

2007-01-17 Thread Nuno Oliveira

Stut wrote:


Redirecting using a Location header is not the only thing you can do 
with the header() function. It will never end processing of the script 
no matter what you pass to it. The example on the manual page for the 
header() function says as much (http://php.net/header), you read that 
right?


?php
header(Location: http://www.example.com/;); /* Redirect browser */

/* Make sure that code below does not get executed when we redirect. */
exit;
?

-Stut



Well, I feel like a du***ss!

No, I hadn't read that. I promisse, and this one is to keep, I won't 
post to this list again without dedicate enough time to the problem, at 
least to read the manual.


Anyway, thank you for confirm what I should have known in advance and 
also for remembering me that PHP developers have a PHP manual for PHP 
users...


Thanks

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



Re: [PHP] email validation string.

2007-01-19 Thread Nuno Oliveira


1. Why did you remove the backslash? (the original was correct)

I have a regular expression tester plugin in firefox and it validates Ok 
with the expression he provided.


If I add the second (original) backslash it won't validate emails anymore.

Also, from my little knowledge of Red.Exp. the backslash will escape special 
chars.
In this case the backslash will escape the dot to match only a dot and not 
all chars...


This my way of seing it...

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



Re: [PHP] email validation string.

2007-01-19 Thread Nuno Oliveira



1. Why did you remove the backslash? (the original was correct)


I have a regular expression tester plugin in firefox and it validates
Ok with the expression he provided.


JavaScript is *not* PHP.



As far as I can read, I never talked about JavaScript...
Maybe the fact that I talked about a browser made you think I was
using Java.

NO! I'm not. This is a php list and I gave my answer based on that.
This plugin I was talking about uses PHP/5.2.0

In either case... Aren't both expressions supposed to validate
an e-mail??

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



Re: [PHP] email validation string.

2007-01-19 Thread Nuno Oliveira

Where can I check out the plugin?


Maybe I shouldn't have mentioned plugin and firefox...

It's not a plugin for firefox like other firefox's plugins...
In fact, when I downloaded somewhere arround the web
the name of the thing (won't call it plugin again) was
Site Programmer Plugin Assistant (or something alike)
and it's just a bunch of php scripts that run as a local
site...

That's why I said that the plugin was using PHP/5.2.0
because that's the php version I have installed.

It needs Apache with PHP support to work and the php
code it uses is a form that processes a text field and do
a ereg($Pattern, $Text) on an if statment that outputs
Match or No Match. Meaning pure PHP (in my case
v5.2.0)

For a real Firefox plugin that shows the matched part
of the text in real time as you change the pattern, you
can search for a plugin (a real one) named Regular
Expressions Tester. I don't have it but you can search
http://www.mozilla.com for it.
Wait... https://addons.mozilla.org/firefox/2077/ this is
the homepage for the plugin.
However, I don't know if this uses Java(script) or what...

About what I asked in my last post... In php, if you have
a string like $Text=[a-zA-Z]+\\. php will save it like
[a-zA-Z]+\. because the first backslash is escaping a
special character which is the second backslash but if
you have the string $Text=[a-zA-Z]+\. php will save it
the exactly the same way because even that the backslash
is used to escape special characters, there is no special
char after it. It's just a dot. So the string gets stored the
same way. Also it doesn't get different with quotes or
double quotes.

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