Hello everyone,
For the result of session_status()
, the corresponding constants for the
sessions state are
-
PHP_SESSION_DISABLED
= 0 -
PHP_SESSION_NONE
= 1 -
PHP_SESSION_ACTIVE
= 2
I'd like to suggest we change these values to
-
PHP_SESSION_DISABLED
= -1 -
PHP_SESSION_NONE
= 0 -
PHP_SESSION_ACTIVE
= 1
This way, one can do if(session_status()) to check if there is an active
session, rather than having to compare the result to a constant.
Any objections?
Thanks,
Justin Martin
Hello everyone,
For the result of
session_status()
, the corresponding constants for the
sessions state are-
PHP_SESSION_DISABLED
= 0
-PHP_SESSION_NONE
= 1
-PHP_SESSION_ACTIVE
= 2I'd like to suggest we change these values to
-
PHP_SESSION_DISABLED
= -1
-PHP_SESSION_NONE
= 0
-PHP_SESSION_ACTIVE
= 1This way, one can do if(session_status()) to check if there is an active
session, rather than having to compare the result to a constant.Any objections?
I believe comparing the value against a constant, is always more
readable than wondering what "truthy" means. if(session_status() ===
PHP_SESSION_ACTIVE) is much self-documenting than the proposed change.
Therefore I object to this change.
- Paul
Thanks,
Justin Martin
I believe comparing the value against a constant, is always more
readable than wondering what "truthy" means. if(session_status() ===
PHP_SESSION_ACTIVE) is much self-documenting than the proposed change.
... also an obvious BC break for anyone who was using the values
instead of the constants before. Not that anyone should ever do this,
but the change presupposes that people do use the values, so it
basically contradicts its own acceptability as it is a breaking
change!
-- S.
On Sat, Jan 28, 2012 at 9:14 PM, Sanford Whiteman
swhitemanlistens-software@cypressintegrated.com wrote:
I believe comparing the value against a constant, is always more
readable than wondering what "truthy" means. if(session_status() ===
PHP_SESSION_ACTIVE) is much self-documenting than the proposed change.... also an obvious BC break for anyone who was using the values
instead of the constants before. Not that anyone should ever do this,
but the change presupposes that people do use the values, so it
basically contradicts its own acceptability as it is a breaking
change!
There is no BC change here as session_status()
has been added in the
5_4 branch as far as i can tell.
-- S.
There is no BC change here as
session_status()
has been added in the
5_4 branch as far as i can tell.
OK, fair enough, I didn't understand it was trying to get into 5.4.
-- S.
Hi!
I'd like to suggest we change these values to
- `PHP_SESSION_DISABLED` = -1 - `PHP_SESSION_NONE` = 0 - `PHP_SESSION_ACTIVE` = 1
This way, one can do if(session_status()) to check if there is an active
session, rather than having to compare the result to a constant.Any objections?
Yes, there's no reason to do that since you can just compare to the
constant - that's why they exist in the first place. Then gain of not
typing couple of characters is much less than the confusion that would
result from changing the constants.
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227
Someone actually just pointed out to me that if(-1) returns true. In
that case, I suppose my suggestion doesn't quite work.
The reason I suggest this is that I suspect people will constantly be
looking up what the constants are called.
Hello everyone,
For the result of
session_status()
, the corresponding constants for the
sessions state are
PHP_SESSION_DISABLED
= 0PHP_SESSION_NONE
= 1PHP_SESSION_ACTIVE
= 2I'd like to suggest we change these values to
PHP_SESSION_DISABLED
= -1PHP_SESSION_NONE
= 0PHP_SESSION_ACTIVE
= 1This way, one can do if(session_status()) to check if there is an active
session, rather than having to compare the result to a constant.Any objections?
Thanks,
Justin Martin
Someone actually just pointed out to me that if(-1) returns true. In
that case, I suppose my suggestion doesn't quite work.
Well, it still "works" depending on what conclusion you want to draw
in your local environment.
Sessions_disabled || yes_active_session might go through the same code
path, while no_active_session might go through another.
-- S.
Someone actually just pointed out to me that if(-1) returns true. In that
case, I suppose my suggestion doesn't quite work.The reason I suggest this is that I suspect people will constantly be
looking up what the constants are called.
Encouraging people to check the manual is a good thing.
As the constants are being used the user doesn't need to consult the
manual at all as PHP_SESSION_DISABLED
is very self-documenting.
Again, a -1 from me.
- Paul.
Hello everyone,
For the result of
session_status()
, the corresponding constants for the
sessions state are
PHP_SESSION_DISABLED
= 0PHP_SESSION_NONE
= 1PHP_SESSION_ACTIVE
= 2I'd like to suggest we change these values to
PHP_SESSION_DISABLED
= -1PHP_SESSION_NONE
= 0PHP_SESSION_ACTIVE
= 1This way, one can do if(session_status()) to check if there is an active
session, rather than having to compare the result to a constant.Any objections?
Thanks,
Justin Martin