[PHP] Re: Session's is slowing the page ??

2002-05-28 Thread Tom Mikulecky

Hi

PHP's sessions are blocking, i.e. until a session is closed, all other calls to
session_start() are pending. If you don't close a session explicitely, it
remains opened until the script is terminated.
The solution is to close a session as soon as possible (session_write_close) or
use non-blocking read-only sessions (session_readonly instead of session_start)
in case you don't need to modify registered variables.

Tom


Dima Dubin wrote:

 Hello,
 I have very wierd problem :
 I use session to manage users and I have this structure of the page :
 -
 include(db.php);
 include(header.php);
 bla bla
 include(footer.php);
 -

 in the db.php I have :

 
 session_start();
 #some mysql connect stuff
 

 I use session with the $_SESSION array (cheking if registered[isset($_S...)]
 and registering...)
 and all work fine
 but sometimes the page loading is very very very slow (and its a really
 really fast host) and when I removing session_start(); from the top of the
 page, the page load normaly.

 the PHP version is 4.1.1, someone have an idea ?
 thanks in advance,
 Dima.


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




[PHP] Re: Session's is slowing the page ??

2002-05-28 Thread Dima Dubin

Hello Tom

I looked in the manual for session_readonly because its basicly what I need
: 1 login page, and the just read the session data in other pages
but, there is no examples or anything like that in the manual could you
please show me a little example how to use it on my pages ?

THANKS !!
Dima.

Tom Mikulecky [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi

 PHP's sessions are blocking, i.e. until a session is closed, all other
calls to
 session_start() are pending. If you don't close a session explicitely, it
 remains opened until the script is terminated.
 The solution is to close a session as soon as possible
(session_write_close) or
 use non-blocking read-only sessions (session_readonly instead of
session_start)
 in case you don't need to modify registered variables.

 Tom


 Dima Dubin wrote:

  Hello,
  I have very wierd problem :
  I use session to manage users and I have this structure of the page :
  -
  include(db.php);
  include(header.php);
  bla bla
  include(footer.php);
  -
 
  in the db.php I have :
 
  
  session_start();
  #some mysql connect stuff
  
 
  I use session with the $_SESSION array (cheking if
registered[isset($_S...)]
  and registering...)
  and all work fine
  but sometimes the page loading is very very very slow (and its a really
  really fast host) and when I removing session_start(); from the top of
the
  page, the page load normaly.
 
  the PHP version is 4.1.1, someone have an idea ?
  thanks in advance,
  Dima.




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




[PHP] Re: Session's is slowing the page ??

2002-05-28 Thread Tom Mikulecky

Login page:


// suppose that user login was verified
// Following code have to be executed only if user is valid

session_start();
session_register(user,user_email);//register here all needed data.
   //In this case, it will register $user
and $user_email in the session

Put the following in session.inc and include session.inc on top of each script
that has to be run for logged users

session_readonly();
if((!session_is_registered(user)) || (!session_is_registered(user_email)))

header(Location: login.php);

This will redirect user to the login page if not logged in. If he was logged,
script will go on and you can access $user and $user_email. Any change of
their value will not be saved in the session

Tom

PS: in my PHP version 4.04 , function session_readonly() is unknown. What I
use instead is:

session_start();

session_write_close();   //session_end is also unknown by 4.0.4



Dima Dubin wrote:

 Hello Tom

 I looked in the manual for session_readonly because its basicly what I need
 : 1 login page, and the just read the session data in other pages
 but, there is no examples or anything like that in the manual could you
 please show me a little example how to use it on my pages ?

 THANKS !!
 Dima.

 Tom Mikulecky [EMAIL PROTECTED] wrote in message
 [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
  Hi
 
  PHP's sessions are blocking, i.e. until a session is closed, all other
 calls to
  session_start() are pending. If you don't close a session explicitely, it
  remains opened until the script is terminated.
  The solution is to close a session as soon as possible
 (session_write_close) or
  use non-blocking read-only sessions (session_readonly instead of
 session_start)
  in case you don't need to modify registered variables.
 
  Tom
 
 
  Dima Dubin wrote:
 
   Hello,
   I have very wierd problem :
   I use session to manage users and I have this structure of the page :
   -
   include(db.php);
   include(header.php);
   bla bla
   include(footer.php);
   -
  
   in the db.php I have :
  
   
   session_start();
   #some mysql connect stuff
   
  
   I use session with the $_SESSION array (cheking if
 registered[isset($_S...)]
   and registering...)
   and all work fine
   but sometimes the page loading is very very very slow (and its a really
   really fast host) and when I removing session_start(); from the top of
 the
   page, the page load normaly.
  
   the PHP version is 4.1.1, someone have an idea ?
   thanks in advance,
   Dima.
 



[PHP] Re: Session's is slowing the page ??

2002-05-28 Thread Dima Dubin

Hi Tom
Thanks for your help but the problem  still happens :-(
First I tried to use session_readonly() but it was unknown FUNC` in my php,
then I try the second way :
I have header.php  footer.php in the header I use session_start(); and in
the footer I use session_write_close() and still every minute the site
freezes.
Is there any other way ? I really need to use these session's...

thanks again for your great help,
Dima.


Tom Mikulecky [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Login page:


 // suppose that user login was verified
 // Following code have to be executed only if user is valid

 session_start();
 session_register(user,user_email);//register here all needed data.
//In this case, it will register
$user
 and $user_email in the session

 Put the following in session.inc and include session.inc on top of each
script
 that has to be run for logged users

 session_readonly();
 if((!session_is_registered(user)) ||
(!session_is_registered(user_email)))

 header(Location: login.php);

 This will redirect user to the login page if not logged in. If he was
logged,
 script will go on and you can access $user and $user_email. Any change of
 their value will not be saved in the session

 Tom

 PS: in my PHP version 4.04 , function session_readonly() is unknown. What
I
 use instead is:

 session_start();
 
 session_write_close();   //session_end is also unknown by 4.0.4



 Dima Dubin wrote:

  Hello Tom
 
  I looked in the manual for session_readonly because its basicly what I
need
  : 1 login page, and the just read the session data in other pages
  but, there is no examples or anything like that in the manual could you
  please show me a little example how to use it on my pages ?
 
  THANKS !!
  Dima.
 
  Tom Mikulecky [EMAIL PROTECTED] wrote in message
  [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
   Hi
  
   PHP's sessions are blocking, i.e. until a session is closed, all other
  calls to
   session_start() are pending. If you don't close a session explicitely,
it
   remains opened until the script is terminated.
   The solution is to close a session as soon as possible
  (session_write_close) or
   use non-blocking read-only sessions (session_readonly instead of
  session_start)
   in case you don't need to modify registered variables.
  
   Tom
  
  
   Dima Dubin wrote:
  
Hello,
I have very wierd problem :
I use session to manage users and I have this structure of the page
:
-
include(db.php);
include(header.php);
bla bla
include(footer.php);
-
   
in the db.php I have :
   

session_start();
#some mysql connect stuff

   
I use session with the $_SESSION array (cheking if
  registered[isset($_S...)]
and registering...)
and all work fine
but sometimes the page loading is very very very slow (and its a
really
really fast host) and when I removing session_start(); from the top
of
  the
page, the page load normaly.
   
the PHP version is 4.1.1, someone have an idea ?
thanks in advance,
Dima.
  




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




[PHP] Re: Session's is slowing the page ??

2002-05-28 Thread Tom Mikulecky

Hat you do is the same as if you do nothing, because your session_write_close()
is called near the end of script and sessions are automatically closed at the
end of a script. You should 'copy' all needed variables from the session in
your header.php like this:

session_start();
$copy_user = $user;//if $user and $user_email are session data
$copy_user_email = $user_email;
session_write_close();//or session_end() if your php knows it

That way you can access $copy_* in the body instead of session variables.
It works as readonly access to session data

Tom

Dima Dubin wrote:

 Hi Tom
 Thanks for your help but the problem  still happens :-(
 First I tried to use session_readonly() but it was unknown FUNC` in my php,
 then I try the second way :
 I have header.php  footer.php in the header I use session_start(); and in
 the footer I use session_write_close() and still every minute the site
 freezes.
 Is there any other way ? I really need to use these session's...

 thanks again for your great help,
 Dima.




[PHP] Re: Session's is slowing the page ??

2002-05-28 Thread Dima Dubin

THANK YOU !!!
Tom Mikulecky [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hat you do is the same as if you do nothing, because your
session_write_close()
 is called near the end of script and sessions are automatically closed at
the
 end of a script. You should 'copy' all needed variables from the session
in
 your header.php like this:

 session_start();
 $copy_user = $user;//if $user and $user_email are session data
 $copy_user_email = $user_email;
 session_write_close();//or session_end() if your php knows it

 That way you can access $copy_* in the body instead of session variables.
 It works as readonly access to session data

 Tom

 Dima Dubin wrote:

  Hi Tom
  Thanks for your help but the problem  still happens :-(
  First I tried to use session_readonly() but it was unknown FUNC` in my
php,
  then I try the second way :
  I have header.php  footer.php in the header I use session_start(); and
in
  the footer I use session_write_close() and still every minute the site
  freezes.
  Is there any other way ? I really need to use these session's...
 
  thanks again for your great help,
  Dima.
 




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




[PHP] Re: Session's is slowing the page ??

2002-05-27 Thread J Smith


It might have something to do with the way the session extension in PHP 
performs garbage collection. There's a setting in php.ini that basically 
controls how often garbage collection is performed. The value is a 
percentage, and determines how often the GC should be done over a random 
number of session_start() requests. 

If GC is invoked, the garbage collector will start to delete all of the 
expired session files in your session directory. If there's a lot of them, 
it might take longer to load the page that the garbage collection was 
started on. Since the garbage collector is called at random based on the 
aforementioned setting, not every page will be affected.

The problem could probably be cut down by increasing the value of the GC 
setting, as fewer files would need to be deleted with each GC sweep, as 
more GC sweeps will be called overall.

That's just a guess, though. 

J


Dima Dubin wrote:

 Hello,
 I have very wierd problem :
 I use session to manage users and I have this structure of the page :
 -
 include(db.php);
 include(header.php);
 bla bla
 include(footer.php);
 -
 
 in the db.php I have :
 
 
 session_start();
 #some mysql connect stuff
 
 
 I use session with the $_SESSION array (cheking if
 registered[isset($_S...)] and registering...)
 and all work fine
 but sometimes the page loading is very very very slow (and its a really
 really fast host) and when I removing session_start(); from the top of the
 page, the page load normaly.
 
 the PHP version is 4.1.1, someone have an idea ?
 thanks in advance,
 Dima.


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




[PHP] Re: Session's is slowing the page ??

2002-05-27 Thread Dima Dubin

Hello J,
I try to change the gc probability in the .htaccess (php_value
session.gc_probability = 10) but it didnt work :-(

Is there any other ideas ? maybe it a bug in PHP ?


THANKS,
Dima.
J Smith [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...

 It might have something to do with the way the session extension in PHP
 performs garbage collection. There's a setting in php.ini that basically
 controls how often garbage collection is performed. The value is a
 percentage, and determines how often the GC should be done over a random
 number of session_start() requests.

 If GC is invoked, the garbage collector will start to delete all of the
 expired session files in your session directory. If there's a lot of them,
 it might take longer to load the page that the garbage collection was
 started on. Since the garbage collector is called at random based on the
 aforementioned setting, not every page will be affected.

 The problem could probably be cut down by increasing the value of the GC
 setting, as fewer files would need to be deleted with each GC sweep, as
 more GC sweeps will be called overall.

 That's just a guess, though.

 J


 Dima Dubin wrote:

  Hello,
  I have very wierd problem :
  I use session to manage users and I have this structure of the page :
  -
  include(db.php);
  include(header.php);
  bla bla
  include(footer.php);
  -
 
  in the db.php I have :
 
  
  session_start();
  #some mysql connect stuff
  
 
  I use session with the $_SESSION array (cheking if
  registered[isset($_S...)] and registering...)
  and all work fine
  but sometimes the page loading is very very very slow (and its a really
  really fast host) and when I removing session_start(); from the top of
the
  page, the page load normaly.
 
  the PHP version is 4.1.1, someone have an idea ?
  thanks in advance,
  Dima.




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