dpacmittal Posted March 18, 2009 Share Posted March 18, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/149939-using-zend-only-for-handling-sessions/ Share on other sites More sharing options...
PFMaBiSmAd Posted March 18, 2009 Share Posted March 18, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/149939-using-zend-only-for-handling-sessions/#findComment-787470 Share on other sites More sharing options...
dpacmittal Posted March 18, 2009 Author Share Posted March 18, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/149939-using-zend-only-for-handling-sessions/#findComment-787481 Share on other sites More sharing options...
PFMaBiSmAd Posted March 18, 2009 Share Posted March 18, 2009 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. Quote Link to comment https://forums.phpfreaks.com/topic/149939-using-zend-only-for-handling-sessions/#findComment-787493 Share on other sites More sharing options...
dpacmittal Posted March 18, 2009 Author Share Posted March 18, 2009 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? Quote Link to comment https://forums.phpfreaks.com/topic/149939-using-zend-only-for-handling-sessions/#findComment-787500 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.