Jump to content

Using Zend Only for handling sessions?


dpacmittal

Recommended Posts

Can I use zend only for handling my sessions in my script. I want to use database based sessions for my php script because file-based is causing some problem(long story).

 

So, how do I go about using the database session handler for my script? I dont know a bit about zend. Could someone help me by posting a tutorial or a guide for accomplishing the task I mentioned above?

Link to comment
Share on other sites

Most problems with the file based session data files are easily solved. What problem are you having?

 

The only practical use for storing session data in a database, because using a custom session save handler is about 100 times slower using parsed/tokenized/interpreted php code than using the built-in complied file save handler, is if you must share session data files between servers, such as when you have load-balanced web servers. Do you actually have a situation where using a custom save handler is necessary or do you just need to solve a simple problem using the normal file save handler?

Link to comment
Share on other sites

Most problems with the file based session data files are easily solved. What problem are you having?

 

Read this:

http://www.phpfreaks.com/forums/index.php/topic,242454.0.html

 

OR just read this:

And, if you hadn’t read this post, you’d have had some hard time finding this out. It is just that in every normal application, you can be 97% sure you will be using sessions. And in most of the time, you will rely on the built-in php sessions’ handler. So far, so good. But the small problem is that you cannot simultaneously be running different scripts ( or more than one instantiation of a script ) which use one and the same user session ( that, again, was a discovery by Mr. Pagebaker ). PHP will just queue all subsequent requests which try to interact with that session, until the first one has been closed. Well, that is not much of an asynchroneous technique either then. Getting back to our chat application - if you want to long-poll the server and wait for new messages ( what we will call read() ) and simultaneously send new messages to the server ( write() ), the application will not write() until the read() request has finished ( which we have set to 5 mins, if in the worst case there is no new data to be received ) - that is absolutely not what we need.

 

This is the exact problem I'm facing. I don't think there's a solution or a hack to this problem.

 

Thats why I needed a database based solution. Problem with cakePHP is that I cannot use only a single component with cakePHP unlike zend.

Link to comment
Share on other sites

Using a custom session save handler won't solve the problem because the access to the session data will still be locked by php until the current script is finished accessing the session data. The simple solution is to use session_write_close to save the session data and close the session as soon as you are done reading or setting the session data in a script.

Link to comment
Share on other sites

Using a custom session save handler won't solve the problem because the access to the session data will still be locked by php until the current script is finished accessing the session data. The simple solution is to use session_write_close to save the session data and close the session as soon as you are done reading or setting the session data in a script.

 

But I reckon, I cannot use start and end a session twice on same page. Can I?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.