Jump to content

Cloud services and lack of session variables


redsmurph

Recommended Posts

I read the conditions for hosting at PHP Fog, and they state that I can't use session variables as such variables are not copied between servers. Therefore I changed session variables for login info, language selection etc to cookies. Hence my own code is now free from session varibables, but Zend that I use for e.g. OAuth is not.

 

Is it typical that cloud hosting providers disallow session variables for the above reason, or are there others that can handle such replication between servers?

 

If not, is work going on to remove use of session variables from popular frameworks?

 

Cheers,

Anders

Link to comment
Share on other sites

They don't disallow it - they can't, there's no way to. But they can tell you that using the normal session is pointless, and it is for the reasons they stated.

 

Except you can use sessions in a database instead. Since all the cloud servers can access the database they can also share the session information. Normal sessions are handled with files and PHP just reads and writes variables and values in them. So instead of files you configure PHP (by writing code) to use a database instead. The rest of the session stuff with  $_SESSION and session_start() still applies without any changes, but behind the scenes PHP goes through some custom code for loading and saving.

Link to comment
Share on other sites

Yes, I meant file-based session variables. That's the default, and that's what PHP Fog doesn't allow.

 

I found this that should help, but I still have to write the code of course:

 

session_set_save_handler('_open', '_close', '_read', '_write', '_destroy', '_clean');

 

Or is there a simpler way?

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.