redsmurph Posted March 10, 2012 Share Posted March 10, 2012 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 https://forums.phpfreaks.com/topic/258656-cloud-services-and-lack-of-session-variables/ Share on other sites More sharing options...
requinix Posted March 10, 2012 Share Posted March 10, 2012 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 https://forums.phpfreaks.com/topic/258656-cloud-services-and-lack-of-session-variables/#findComment-1325925 Share on other sites More sharing options...
redsmurph Posted March 10, 2012 Author Share Posted March 10, 2012 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 https://forums.phpfreaks.com/topic/258656-cloud-services-and-lack-of-session-variables/#findComment-1325943 Share on other sites More sharing options...
requinix Posted March 10, 2012 Share Posted March 10, 2012 Besides finding some library that does the session+database stuff already, not really. Link to comment https://forums.phpfreaks.com/topic/258656-cloud-services-and-lack-of-session-variables/#findComment-1325964 Share on other sites More sharing options...
redsmurph Posted March 10, 2012 Author Share Posted March 10, 2012 I wrote my own override functions. Link to comment https://forums.phpfreaks.com/topic/258656-cloud-services-and-lack-of-session-variables/#findComment-1325968 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.