deda-ca / cgi-node

CGI Node.js complete module to replace PHP on shared hosting such as GoDaddy
http://www.cgi-node.org/
MIT License
172 stars 21 forks source link

Session path invalid on most enviroments #5

Open arschmitz opened 9 years ago

arschmitz commented 9 years ago

The session path is set to D:/Programs/nodejs/sessions/ in both the dev and min versions for download yet the instructions just tell you to change the path on the first line ( in the minified file is is actually buried in the minified code )

The instructions to update the path to node should also mention you need to set and create a folder for the session storage.

Also possibly worth noting about different enviroments the quotes around the path to the node executable are not valid on osx or linux and is easy for people not so familier with how cgi paths work to miss

deda-ca commented 9 years ago

Excellent points and suggestions. I'll update the documentation and code accordingly. Thanks

arschmitz commented 9 years ago

Thanks. like what you have done so. I ran into very few issues using it to convert some simple php examples for a talk on using node as a cgi, I gave yesterday, people seemed pretty interested. Keep up the good work!

iwonbigbro commented 9 years ago

You could use an environment variable for NODE_SESSION_DIRECTORY, so you don't have to hard code paths. Also, the script fails if the directory doesn't exist. Perhaps you should create it in the event it is not present.

tmalaher commented 8 years ago

Here are my diffs, around about line 290:

                var path = Path.join(CgiNodeConfig.SessionPath, this.id);

+               // If the session dir does not exist then create it
+               if (!FS.existsSync(CgiNodeConfig.SessionPath)) FS.mkdirSync(CgiNodeConfig.SessionPath);
                // If the file does not exist then create another ID.
                if (!FS.existsSync(path)) this.id = this.create();

But that's the minimal change to get it working... you should consider using https://www.npmjs.com/package/mkpath to ensure the whole path exists. And you should probably specify the mode to set the session directory to only be readable/writable by the user, so the session file contents are private to the web server process user.