Jump to content

File Based Session Handling


Guest Kulsha

Recommended Posts

Hi there

My web hosting company requires me to change the session save path from the standard /tmp to my own folder in the home directory instead.

I have created a folder called _sessions and put it on my server. They instruct me to put the following in my code:

ini_set("session.save_handler", "files");

session_save_path ("path to _sessions folder");

Problem is I'm not sure where to put this code... I have done a search on all of the files within cubecart and I think there are 6 files that have "session_start();" mentioned. I have put that code, directly above this "sessions_start();". Maybe I am meant to delete something in return...

Before I add the code, when visiting the install home page, I get the message on my browser:

Fatal error: session_start() [<a href='function.session-start'>function.session-start</a>]: Failed to initialize storage module: user (path: /tmp) in /clientdata/www/au/xxxxxx/install/index.php on line 30

Is there a way I can change session path to 'files' in one central location. The code that my web host suggests above actually creates a page full of errors - but then again I might be putting it in wrong, may I have to delete something? I'm not a programmer and don't know php unfortunately.

Any clues, greatly appreciated. I am assuming the files involved are:

admin/login.php

admin/logout.php

admin/includes/auth.inc.php

admin/misc.php

includes/sessionStart.inc.php

install/index.php

but if this is wrong, please tell me.

Thanks :P

Link to comment
Share on other sites

includes/ini.inc.php is the best location, this file is always loaded even by installation.

Install CubeCart: please modify install/index.php:

SEARCH FOR

session_start();



include("../includes/ini.inc.php");






REPLACE WITH
include("../includes/ini.inc.php");



session_start();

Link to comment
Share on other sites

Thanks for that but to my dismay... now I get even more errors:

Warning: session_start() [function.session-start]: open(/clientdata/clients/d/a/x.com.au/www/sessions//sess_62a2a48b0937185bd0209d1cacfc4b84, O_RDWR) failed: No such file or directory (2) in /clientdata/www/au/d/x.com.au/nt/install/index.php on line 32

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /clientdata/www/au/d/x.com.au/nt/install/index.php:32) in /clientdata/www/au/d/darwinsearch.com.au/nt/install/index.php on line 32

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /clientdata/www/au/d/x.com.au/nt/install/index.php:32) in /clientdata/www/au/d/x.com.au/nt/install/index.php on line 32

Warning: Cannot modify header information - headers already sent by (output started at /clientdata/www/au/d/x.com.au/nt/install/index.php:32) in /clientdata/www/au/d/x.com.au/nt/install/index.php on line 40

Warning: Unknown(): open(/clientdata/clients/d/a/x.com.au/www/sessions//sess_62a2a48b0937185bd0209d1cacfc4b84, O_RDWR) failed: No such file or directory (2) in Unknown on line 0

Warning: Unknown(): Failed to write session data (files). Please verify that the current setting of session.save_path is correct (/clientdata/clients/d/a/x.com.au/www/sessions/) in Unknown on line 0

To make sure I understood what you said:

1. I uploaded all of cubecart files to my host

2. Added the code to the includes/ini.inc.php file:

ini_set("session.save_handler", "files");

session_save_path ("path to _sessions folder");

3. Then swapped that bit of code you mentioned below to the install/index.php file

It looks like its sort of worked in that it is now trying to access the right directory... instead of the tmp one but the other messages look scarey now. Please let me know if I've missed any step even if it might be obvious to you (I'm non-programmer and have no idea!)

Thanks

B)

Hello...

Can anyone suggest anything here? I still cannot install cubecart at all on my server and don't know what to do!

Thanks :)

Link to comment
Share on other sites

Guest Brivtech

I'm completely stuck on this one, as I haven't come across this happening with hosting before. Can your host provide any details of they would recommend how to set up the file-based session handling?

Link to comment
Share on other sites

Guest EverythingWeb

Most, if not all PHP session handling is done file based :dizzy:

Usually, the /tmp folder has loads of files in it, called sess_439247893289 and they are the session files that apache/php uses. What this customer is being asked by their webhost, is to not have those text files stored in /tmp, but rather in their own home directory (thus taking up their own quota etc - I would presume).

Without knowing the server, software or what you have config'd I could only suggest making sure the newly created sessions folder is CHMOD'd 777 and that you have got the paths absolutely correct :)

Link to comment
Share on other sites

@Kulsha

Just follow the error notes:

"Please verify that the current setting of session.save_path is correct (/clientdata/clients/d/a/x.com.au/www/sessions/)

open(/clientdata/clients/d/a/x.com.au/www/sessions//sess_62a2a48b0937185bd0209d1cacfc4b84, O_RDWR)

Take care on paths as EverythingWeb posted above, do not use slash at the end of path.

Link to comment
Share on other sites

Thanks, getting the path correct was the key, my hosting instructions clearly said to use the format:

/clientdata/clients/d/a/x.com.au/www/ so I uploaded phpinfo.php and discovered it should have been

/clientdata/www/au/d/x.com.au/

I have sent a ticket to complain about their instructions!

I can now get it to work with the base install but when I try and install my own modified store which I developed on my local WAMP server PC, I now get:

MySQL Error Occured

1146: Table 'xx_com_au.CubeCart_sessions' doesn't exist

QUERY = INSERT INTO CubeCart_sessions (`location`, `sessId`, `timeStart`, `timeLast`, `customer_id`) VALUES ('/xx/index.php', '7b3054f7659fa73b89680cf45951290a', '1171837608', '1171837608', 0)

I noticed in my database my CubeCart_sessions table is all in lowercase (probably created it like that because of WAMP, windows thing?) - so maybe its case sensitive on my Linux remote web server. I tried changing the name in phpmyAdmin to make it with the capital letters but that didn't work - it still says it doesn't exist, but it DOES exist!!

I have checked the forum and the solution for most people was that they had to import or set up a database, but I have done this. I exported my localhost store to a SQL file then imported this backup into my remote webhost database area via PHPMyAdmin.

Any other ideas...? I can't believe its taken ages to get past this sessions problem and now I have another (hopefully not serious) error to replace it...

Thanks.

:yeahhh:

Link to comment
Share on other sites

Wow what a mess, I've just done a search on 'CubeCart_' and replaced with 'cubecart_' in all of the source files, there was over 1000 entries. Hope this fixes it... kept a backup of course.

I'm wondering why the code is written with uppercase/lowercase, you'd think they would cater for both systems by keeping everyone happy with lowercase.

Surely other people must develop on their local windows pc then upload final website to their web hosting company which is usually Linux... :)

Link to comment
Share on other sites

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.   Paste as plain text instead

  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...