[phpa] Re: Problem with changing PHP files

  • From: Steve Brown <steve@xxxxxxxxxxxxxxxxxx>
  • To: phpa@xxxxxxxxxxxxx
  • Date: Thu, 07 Mar 2002 10:48:59 -0800

At 02:32 07/03/2002, you wrote:

>Steve,
>
> > Definitely! I had to desist using phpa temporarily - which is sad cos it
> > royally speeds things up and is likely to grease our server nicely now we
> > have session-mysql.php handling all the sessions too (which basically
>means
> > the sessions went from native code to an included PHP file every request!)
> > so it'd be nice to get it back :)
>
>Not related to the problem with changing PHP files, but do you have any
>point you can send me to get info (or scripts) about session-mysql.php? We
>have a couple of problems with our session files in /tmp and I'd like to try
>this solution. Instead of looking what is available, maybe I could use your
>tested method.
>
>Alex


Hi Alex,
    (sorry Nick, if you'd rather I moved this conversation off list just 
yell :))

         Visit http://www.phpbuilder.com/columns/ying20000602.php3 and 
fetch down the ying.zip he has on there. That contains session_mysql.php 
which you need to bung somewhere on your system. I made some changes 
because its a little broken in one place and a little inefficient in another.

1) I added this to the very top;
if ( defined("SESSION_HANDLER") )
{
   return;
}
else
{
   define("SESSION_HANDLER", "Yes");
}

2) In sess_read() you need to change return false; into return "" otherwise 
you'll get a seg fault in Apache every time a new session is needed.

3) I changed the insert into query in sess_write() to be a replace into 
query, which should save on updates (the present system tries to insert and 
if it fails then it does an update instead. I replaced the insert with 
replace so that the db can do all that).

4) I added the file to the auto_prepend variable in php.ini so that its 
automatically called for any script (hence the addition in part 1 to 
protect against it getting called twice for any reason)

Anyway, it seems to work a treat for us.

Steve.

------------------------------------------------------------------------
  www.php-accelerator.co.uk           Home of the free PHP Accelerator

To post, send email to phpa@xxxxxxxxxxxxx
To unsubscribe, email phpa-request@xxxxxxxxxxxxx with subject unsubscribe


Other related posts: