简体   繁体   中英

PHP 5.4 sessions not working correctly

I recently switched over from PHP 5.3 to 5.4 and now my sessions are not saving correctly. I am getting errors saying that the location of the session folder does not exist but when I check my phpinfo(), it is the correct location. Also, I am unfortunately using godaddy for my hosting so I cannot access my php.ini file. I have stated session_start() on every page, I tried setting the save path to something else and that got rid of the errors but after that the sessions still were not saving.

Here is one of the errors.

Warning: session_start(): open(D:\\Temp\\php\\session\\sess_c6p2sphcn5m00g4ev48vfmj3h4, O_RDWR) failed: No such file or directory (2) in D:\\Hosting\\12059488\\html\\log.php on line 4

I don't have an answer for this problem yet, but here is what I have learned so far:

In Godaddy shared hosting, you do not have access to "D:\\Temp\\php\\session", which is the default location where PHP will try to use to store its session data.

You can create a folder in root of your own directory (eg tmp), give write access to web server and make it unreadable from web (using File Manager), then in your PHP code before "session_start();" add something like this:

session_save_path("D:\\Hosting\\12059488\\html\\tmp");

Even this may file if you are using the new "Web Hosting" plans (in contrast to "Classic" plans) as Godaddy says these new plans do not support sessions and shared files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM