Re: [PHP] Sessions: Trigger a new one, Expire an old one

2002-10-16 Thread Jonathan Sharp

Your example for the cookie session works, but I wanted to keep sessions 
'transparent' and not have to manage sessions.

The code I wrote basically finds the session id wherever it might be, 
checks if it's expired, if so, it then removes all traces of the session 
id to make session_start() think that there is not already a session...

-js


Max Buvry wrote:
> Hi,
> 
> I use php 4.2.3 with session.auto_start = 1 in php.ini
> 
> 
> What I use with URL session :
> 
>   $_SESSION= array();
>   unset($_GET[session_name()]);
>   session_destroy();
>   Header("Location: next_script.php");
> 
> with cookie session :
> 
>$cook_param= session_get_cookie_params();
>$life_time= $cook_param['lifetime'];
>$path= $cook_param['path'];
>setcookie(session_name(),"",$life_time,$path);
>$_SESSION= array(); 
>session_destroy();
> 
> mb
> 
> 
> 
> Jonathan Sharp wrote:
> 
>>Ok, here is my solution:
>>
>>I wanted this to be as self contained as possible:
>>
>>function clean()
>>{
>>/* get name of session & find session id */
>>$name = ini_get('session.name');
>>$sessid = ( !$_COOKIE[$name] ?
>> ( !$_GET[$name] ?
>> ( !$_POST[$name] ? false :  $_POST[$name] ) :
>> $_GET[$name] ) :
>> $_COOKIE[$name] );
>>
>>/* run query now to see if sesion is expired, if yes */
>>unset( $_COOKIE[$name] );
>>unset( $_GET[$name] );
>>unset( $_POST[$name] );
>>unset( $_REQUEST[$name] );
>>}
>>
>>clean();
>>session_start();
>>
>>Since _COOKIE/etc needs to be UNSET before session_start is called and
>>re-calling session_start does sqat, the above code (not all of it but
>>general idea) 'finds' the session id (session_id() has no effect until
>>session_start is called) and tests to see if it's expired, if so, it
>>'kills' all possible locations for session_start() to find an id.
>>
>>*simple*... (or something like that)
>>
>>-js
>>
>>Chris Shiflett wrote:
>>
>>>Yeah, John hinted at the answer there.
>>>
>>>You just need to make the session ID go away prior to starting the
>>>session . Just unset it or set it to the empty string or whatever you
>>>want to do.
>>>
>>>It is probably either $_COOKIE["PHPSESSID"] or $_GET["PHPSESSID"].
>>>
>>>Chris
>>>
>>>John W. Holmes wrote:
>>>
>>>
>"Simple" question. If a users session expires or has timed out, how do
>
>I 'force' php to generate a new sessionId?
>

Session_start() ??

If there isn't a session id present, it'll create one.

---John Holmes...

>>>
>>>
> 




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




Re: [PHP] Sessions: Trigger a new one, Expire an old one

2002-10-16 Thread Max Buvry


Hi,

I use php 4.2.3 with session.auto_start = 1 in php.ini


What I use with URL session :

  $_SESSION= array();
  unset($_GET[session_name()]);
  session_destroy();
  Header("Location: next_script.php");

with cookie session :

   $cook_param= session_get_cookie_params();
   $life_time= $cook_param['lifetime'];
   $path= $cook_param['path'];
   setcookie(session_name(),"",$life_time,$path);
   $_SESSION= array(); 
   session_destroy();

mb



Jonathan Sharp wrote:
> 
> Ok, here is my solution:
> 
> I wanted this to be as self contained as possible:
> 
> function clean()
> {
> /* get name of session & find session id */
> $name = ini_get('session.name');
> $sessid = ( !$_COOKIE[$name] ?
>  ( !$_GET[$name] ?
>  ( !$_POST[$name] ? false :  $_POST[$name] ) :
>  $_GET[$name] ) :
>  $_COOKIE[$name] );
> 
> /* run query now to see if sesion is expired, if yes */
> unset( $_COOKIE[$name] );
> unset( $_GET[$name] );
> unset( $_POST[$name] );
> unset( $_REQUEST[$name] );
> }
> 
> clean();
> session_start();
> 
> Since _COOKIE/etc needs to be UNSET before session_start is called and
> re-calling session_start does sqat, the above code (not all of it but
> general idea) 'finds' the session id (session_id() has no effect until
> session_start is called) and tests to see if it's expired, if so, it
> 'kills' all possible locations for session_start() to find an id.
> 
> *simple*... (or something like that)
> 
> -js
> 
> Chris Shiflett wrote:
> > Yeah, John hinted at the answer there.
> >
> > You just need to make the session ID go away prior to starting the
> > session . Just unset it or set it to the empty string or whatever you
> > want to do.
> >
> > It is probably either $_COOKIE["PHPSESSID"] or $_GET["PHPSESSID"].
> >
> > Chris
> >
> > John W. Holmes wrote:
> >
> >>> "Simple" question. If a users session expires or has timed out, how do
> >>>
> >>> I 'force' php to generate a new sessionId?
> >>>
> >>
> >> Session_start() ??
> >>
> >> If there isn't a session id present, it'll create one.
> >>
> >> ---John Holmes...
> >>
> >
> >

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




Re: [PHP] Sessions: Trigger a new one, Expire an old one

2002-10-15 Thread Jonathan Sharp

Ok, here is my solution:

I wanted this to be as self contained as possible:

function clean()
{
/* get name of session & find session id */
$name = ini_get('session.name');
$sessid = ( !$_COOKIE[$name] ?
 ( !$_GET[$name] ?
 ( !$_POST[$name] ? false :  $_POST[$name] ) :
 $_GET[$name] ) :
 $_COOKIE[$name] );

/* run query now to see if sesion is expired, if yes */
unset( $_COOKIE[$name] );
unset( $_GET[$name] );
unset( $_POST[$name] );
unset( $_REQUEST[$name] );
}


clean();
session_start();

Since _COOKIE/etc needs to be UNSET before session_start is called and 
re-calling session_start does sqat, the above code (not all of it but 
general idea) 'finds' the session id (session_id() has no effect until 
session_start is called) and tests to see if it's expired, if so, it 
'kills' all possible locations for session_start() to find an id.

*simple*... (or something like that)

-js


Chris Shiflett wrote:
> Yeah, John hinted at the answer there.
> 
> You just need to make the session ID go away prior to starting the 
> session . Just unset it or set it to the empty string or whatever you 
> want to do.
> 
> It is probably either $_COOKIE["PHPSESSID"] or $_GET["PHPSESSID"].
> 
> Chris
> 
> John W. Holmes wrote:
> 
>>> "Simple" question. If a users session expires or has timed out, how do
>>>   
>>> I 'force' php to generate a new sessionId?
>>>   
>>
>> Session_start() ??
>>
>> If there isn't a session id present, it'll create one.
>>
>> ---John Holmes...
>>
> 
> 




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




Re: [PHP] Sessions: Trigger a new one, Expire an old one

2002-10-15 Thread Chris Shiflett

Yeah, John hinted at the answer there.

You just need to make the session ID go away prior to starting the 
session . Just unset it or set it to the empty string or whatever you 
want to do.

It is probably either $_COOKIE["PHPSESSID"] or $_GET["PHPSESSID"].

Chris

John W. Holmes wrote:

>>"Simple" question. If a users session expires or has timed out, how do
>>
>>
>>I 'force' php to generate a new sessionId?
>>
>>
>Session_start() ??
>
>If there isn't a session id present, it'll create one.
>
>---John Holmes...
>


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




RE: [PHP] Sessions: Trigger a new one, Expire an old one

2002-10-15 Thread John W. Holmes

> "Simple" question. If a users session expires or has timed out, how do
I
> 'force' php to generate a new sessionId?
> 
> I wrote a handler that stores sessions into a mysql table, and am able
> to test if it has expired or not. But how do I get php to start a new
one?

Session_start() ??

If there isn't a session id present, it'll create one.

---John Holmes...



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




[PHP] Sessions: Trigger a new one, Expire an old one

2002-10-15 Thread Jonathan Sharp

"Simple" question. If a users session expires or has timed out, how do I 
'force' php to generate a new sessionId?

I wrote a handler that stores sessions into a mysql table, and am able 
to test if it has expired or not. But how do I get php to start a new one?

-js


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