NYCPHP Meetup

NYPHP.org

Subject: Re: [nycphp-talk] PHP 4.3.3 and session_start

felix zaslavskiy felix at students.poly.edu
Fri Feb 27 10:09:29 EST 2004


> Because these courses where produced by different programmers working
> for different shops, I need to ask them to modify their code and check
> first if a session already exists before calling session_start. This
> is not fun.
> 

You can check for session existance manually
if(isset($_COOKIE[session_name()]) || isset($_GET[session_name()] ))
This does still miss one case where sid can be part of url
http://host/sessesion_name-session_id/...

What you got to realize is that these checks are the first thing done by
session_start() before it sets php internal session status to on or off.
There shoudl be no reason to write this session check code when it is
already done by php.

Also it does not make sence to use isset($_SESSION) before
session_start() is called.

What php really needs is an additional session_exists()  function.

Code like this:
 if(!session_exists()){ session_start(); } 
would not be useful because that is already what session_start() does.

Although this would be useful:
 if(!session_exists()){
   //do something without starting session
 }else{
  	session_start();
        //do normal session stuff
 }


-- 
felix[at]bebinary.com
http://www.zaslavskiy.net/




More information about the talk mailing list