software development



I wonder if someone can help me with a pointer to information on code samples for SESSION that will work on Dreamhost. I’m not a PHP coder but our technical developer is striking some trouble and I have seen that others have occasionally had issues due to the nature of the PHP implementation in the DH shared hosting environment. The message from them is below and if anyone had any clues I’d greatly appreciate it!



We are having query about the SESSION.
Our coding for session is not working.

We have check your server details

Please ask your hosting provider to send me sample code for how to session will work on this server.

Our coding is working fine on



Without seeing your technical developer’s code, I could only guess why he/she might be having trouble, and is the authoritative guide on “sample code for how to session will work” on any server.

Between the phpinfo() output your developer has, and the manual, there are no special “tricks” to getting session code to work on DreamHost.

There are some significant differences between the two environments in which your developer is working, and his/her code needs to take this into consideration:

  1. DreamHost is running PHP-CGI, while the other server is running mod_php

  2. DreamHost is running PHP 5.2.3, while the other server is running PHP 4.4.4

  3. Dreamhost is running with register_globals disabled, while the other server is running with them enabled.

  4. DreamHost has allow_call_time_pass_reference off, while the other has it on (same for allow-url-fopen)

… and probably others. Your developer needs to take these issues under consideration with his code (though not all of these differences are relevant to sessions handling).

One thing you might consider trying, if you do not object to running code under PHP4, is to change your DreamHost domain to use PHP4 instead of PHP 5 (you can do that in the control panel). That will eliminate some of the differences in the environments (to the detriment of security on the DreamHost side :frowning: ) and, depending upon your developer’s code,may help him get his/her code working.

That said, you are far better off, as is your developer, in getting his code to work in the more secure DreamHost environment using PHP5, IMHO. :wink:

Edited to provide additional info: Your developer can good examples of robust session handling code in the open source of several of the applications DreamHost offers as “one-click” installs. Particularly, I think that Joomla! offers some fine examples!

At a “simpler” level, here are two php scripts that demonstrate handling sessions in the DreamHost PHP 5.2.3 environment:

First, storing to session…

// Store to session
$_SESSION[‘mySessionName’] = “sessionidentifier”;
Next, reading from session…

// read from session
echo $_SESSION[‘mySessionName’];



RLP is typically right on point so I won’t try to add too much, but I also wonder about the way that the session scope is implemented in the code you’re running.

I noticed from the phpinfo page that your other host is running PHP Version 4.4.4

I can’t recall if syntax like “$HTTP_SESSION_VARS[‘username’]” was supported in that version, but I do know that it isn’t supported in PHP5 on DH, which you appear to be running from the looks of the other phpinfo page you posted.

All I can say is that most of the websites I host here utilize the session scope without any problems, and I have never heard of any issues resulting from DH configuration like you mentioned in your post.

Two things in closing… 1) can you give us specifics/code samples to further clarify the problem you’re experiencing, 2) what sort of session scope issues are you talking about when you refer to others with occasional issues?


Many thanks to both RL Parker and pangea33 for your helpful and insightful replies!

I have forwarded this to the developers and they have solved the problem. It sounds like it would have been the PHP version issue.

As a long-time DH user (coming up to 10 years) I’ve always felt that the friendliness of the community was a big differentiator from other hosts, and this episode has proven that to me again. I realise it was a bit of a noob question so thanks heaps for the support.