You are here: Re: Setting my own session handler.. « PHP Programming Language « IT news, forums, messages
Re: Setting my own session handler..

Posted by Erwin Moller on 06/19/07 13:04

Jerry Stuckle wrote:

> PaowZ wrote:
>> On 19 juin, 00:42, Jerry Stuckle <jstuck...@attglobal.net> wrote:
>>> PaowZ wrote:
>>>> Hello There!
>>>> I'm trying to handle sessions using php5, but having some troubles to
>>>> design it..
>>>> Ok, I have to use "session_set_save_handler()" to override session
>>>> management but I don't really understand callback functions arguments.
>>>> According to doc (http://fr3.php.net/manual/fr/function.session-set-
>>>> save-handler.php french version),
>>>> open(), close() take not arg, read() takes $id, write() takes $id,
>>>> $sess_data and so on...
>>>> But too few doc about it.. a little may be found there:
>>>> http://shiflett.org/articles/storing-sessions-in-a-database
>>>> My question: do we have to take in account these args ? May I
>>>> implement my callback functions without supplying those arguments but
>>>> my own ones ? How have I to consider it ? :)
>>>> Any suggestions ?
>>>> Thanks a lot.
>>> You need to use the supplied args. For instance, the $id in read and
>>> write is the session id.
>>>
>>> These functions are called by PHP, not your code. They must be
>>> compatible with PHP's session handling code.
>>>
>>> --
>>> ==================
>>> Remove the "x" from my email address
>>> Jerry Stuckle
>>> JDS Computer Training Corp.
>>> jstuck...@attglobal.net
>>> ==================
>>
>> Ok, thanks. I don't have the choice, then..
>> Where may I find documentation about all of that ??
>>
>> Thanks :)
>>
>
> Basically, the PHP manual is about all there is. Not good, I admit.
> But I don't know of anything better.
>

Hi,

Zend has a few articles concerning database storage of own sessionhandlers,
including some code to get you going.
Go to www.zend.com and search (upper right) for 'session_set_save_handler
tutorial'.
The first searchresult points to an article by Matt Wade, that pretty much
covers the issue.

It helped me more when building my own than www.php.net.

One tip when testing your own handler:
1) create a page testsession.php.
This page only reads a var in the session and increases it by 1.
eg:
if (!isset($_SESSION["mycounter"]){
$_SESSION["mycounter"] = 1;
}
echo "mycounter = ".$_SESSION["mycounter"] ;
$_SESSION["mycounter"]++;


2) Create a page with 10 or more frames that all hold testsession.php.

If you load this page, you'll see 10 times the output, which should never
contain any doubles.
This is an easy way to test for possible concurrency problems.

Good luck.
Regards,
Erwin Moller

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация