Re: PHP session variables

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

 



On 08/09/2012 01:45 PM, Tedd Sperling wrote:
On Aug 8, 2012, at 5:41 PM, Jim Giner<jim.giner@xxxxxxxxxxxxxxxxxx>  wrote:

On 8/8/2012 11:24 AM, Ansry User 01 wrote:
I am setting the _SESSION variables in one of my file, but whenever I leave the php page session variables are not accessible. Not sure what I need to do additionally other then defining _SESSION[].
Any pointer.

You must make it a habit to start each script with

session_start();


I like this way:

if (!session_id())
	{
	session_start();
	}

Cheers,

tedd

_____________________
tedd@xxxxxxxxxxxx
http://sperling.com



You are relying on PHP's loose typing.  This is a poor check.

session_id() returns a string, not boolean.

You should do this instead.

if ( session_id() === '' )
....


--
Jim Lucas

http://www.cmsws.com/
http://www.cmsws.com/examples/

--
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