sessions or cookies is the way you probably want to go.

you could pass the variable around to each and every
form, but that is a pain in the ass, and extremely
prone to errors.

on the first page, where you check the user's ability to 
use attachments, you could simply set a cookie

setcookie('cookie_can_use_attachments', ... );

and on subsequent pages, check to see if the variable
$cookie_can_use_attachments is set

or, if you plan to carry arounc more information from
page to page than just the user's ability to use attachments,
sessions will make your life much easier 

best of luck.

> -----Original Message-----
> From: Santiago Romero [mailto:[EMAIL PROTECTED]]
> Sent: Friday, July 13, 2001 2:12 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP] Re: How to maintain a variable between PHP pages
> (sessions?).
> 
> 
>  Hi!
> 
>  How is possible to maintain a PHP variable defined on a PHP3 file
>  (IMP 2.2.5, mailbox.php3) so that is available for another PHP3
>  file (compose.php3) and for future reloads of mailbox.php3?
> 
>  I have a variable called can_use_attachs (can_use_attachs) that
>  is checked on an LDAP server on mailbox.php3 and used on compose.php3.
>  The idea is just to check the LDAP server just once (the first
>  time) and set that variable so that future reloads do not check the
>  ldap server another time.
> 
>  I'm using the following code, but I suspect that produces a segmen-
>  tation fault one time each about 4000 reloads (yes, I can reload
>  the page thousands of times automatically, and when I reach about
>  4000 it produces a segmentation fault on token_cache.c):
> 
> // the beginning of my mailbox.php3 file
> if( !isset( $can_use_attachs ) )
> {
>  $ds=ldap_connect("192.168.1.152");
> 
>  if ($ds)
>  {
>    $r=ldap_bind($ds);
>    $busca="uid=" . $imp->user;
>    $sr=ldap_search($ds,"cn=Correo,o=sistemas.servicom2000",
>                    $busca);
>    if( ldap_count_entries($ds,$sr) < 1 )
>      SetCookie( "can_use_attachs", 'n', time()+3600 );
>    else
>    { 
>      $info = ldap_get_entries($ds, $sr);
>      if( $info[0]["roomnumber"][0] == "s" )
>        SetCookie( "can_use_attachs", 's', time()+3600 );
>      else
>        SetCookie( "can_use_attachs", 'n', time()+3600 );
>    }
>    ldap_close($ds);
>  }
> }
> 
>  And in compose.php3:
> 
> <? if( $can_use_attachs == 's' ) { ?>
> 
>  <input type="hidden" name="attachmentAction" value="">
>  (etc...)
>  <?php endif; ?>
> 
> <?php } ?>
>  
> 
>  Does anyone know a better way of doing the above? I don't know how
>  to use PHP sessions (as used on Horde/IMP) so that I don't need
>  cookies to set up that variable.
>  
> PS: and if someone can see in the above code what could be the 
> cause of the segmentation fault, please tell me.
> 
>  CU and thanks a lot.
> -- 
> Santiago Romero
> Departamento de Sistemas
> [EMAIL PROTECTED]
> 
> Av. Primado Reig 189, entlo
> 46020 Valencia - Spain
> Telf. (+34) 96 332 12 00
> Fax. (+34) 96 332 12 01
> http://www.servicom2000.com
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to