Help with PHP Session Start - php

my program gives me this error, - Warning-PHP Function_start(); C:/PHp\tmp no such file or directory.
What do i do?
the session save thingy is pointing to windows temp.
Thank You

This basically means, that PHP is trying to store the session data in a directory which doesn't exist. Make sure that C:/PHP/tmp is actually a valid directory.

double check that the session save path (c:\PHP\tmp) is a valid directory. Also you can check php.ini and look at the session.save_path config option to see what it is set to. You might need to change it to another folder.

Make sure your files inside that directory are not corrupted. Have you edited these files at all? Check if all the files are there what should be there.

Related

PHP session warning in Windows IIS

Error during session start; please check your PHP and/or webserver log file and configure your PHP installation properly. Also ensure that cookies are enabled in your browser.
session_start(): open(C:\Windows\TEMP\sess_3ls3qdk77m9mhsf5tm1cdhrm05bi5kb1, O_RDWR) failed: Invalid argument (22)
in my php.ini file: session.save_path = "C:\temp\phpsessions"
Before it was working fine. So sudden it is showing an error.
anyone can assist with this please.
As already stated by other, there is a chance that
Either the C:\temp\phpsessions directory doesn't exist,Or
Else IIS_IUSRS Read/Write Permission is missing in C:\Windows\Temp
there is no problem with your browser.
Double check the permissions on C:\Windows\Temp\ folder. I think IIS_IUSRS needs to have write access in order for files to be saved.
Consider moving the session folder out of C:\Windows\
Where ever you put the sessions, iis will need permissions to edit it.
PHP will not create this directory structure automatically. So make sure this C:\temp\phpsessions directory exist. If not, then you can use the script in the ext/session dir for that purpose or create that directory structure manually.
and then
You can change session save path by writing this line for created directory before session start also note here extra '\' because of escape character.
session_save_path("C:\\temp\\phpsessions");
Most probably it is browser problem. Some mistmatch between browser and session data.
Just in case please do the following:
1. Clear the cache, cookies and temp data of your browser (or use another browser for experimental purposes).
2. Clear the directory where session files are stored on serverside (in your case it seems it is C:\Windows\TEMP or C:\temp\phpsessions. Better clean both of them).
If it does not work please share your php.ini file.

Sessions storage php/nginx

I'm having trouble with session variable in my setup. I'm storing some data in SESSION variables, but it seems like they're not stored properly, or at least I can't access them. On my local computr running MAMP it works ifne but in prod with php5/nginx, my session variables aren't stored. (I get an undefined index error).
I've read it can be related to the session.save_path and access rights, but I'm still confused. Where is this path defined? In my php.ini file there is this
;session.save_path = "/var/lib/php5"
But it starts with a ';' so I'm guessing it's ignored?
Also, what access should I give to the folder (once I've found it)? How can I know which user php is, and which group it belongs to? Seems like really basic stuff but I'm struggling to grasp it u__u
EDIT:
Apparently it's not a problem of permissions, since there are a lot of session folders in the directory, all created by php... So I really can't figure out why my session variables aren't accessible! :-(
It says undefined index...
Thanks in advance!
Aurélie
It is indeed ignored if it starts with ;. The default value is the temp directory, i.e. /tmp, but just to be sure, I suggest that you look in your phpinfo() and check it there because the file you checked might not be the only configuration your PHP uses.
The sessions path needs to be writable by PHP and it also has to be permitted by the open_basedir directive (if you use open_basedir which is highly recommended).
You use nginx so I'll assume you're using PHP-FPM. To find the PHP-FPM's user, you need to either find the user = ... directive in your php-fpm.conf (usually somewhere under /etc), or you can just find the running process using a tool like ps, htop, etc.

How to save sessions outside of webroot;

I am trying to save sessions outside of the web root. my website root folder is
public_html -> example.com
The sessions folder i have created is a sibling of the public_html folder. I don't know how to reach it. I tried below but i get an error.
session.save_path = /sessions;
How do i solve this?
The path you give needs to be in quotes; that may be all that's wrong here:
session.save_path = "/sessions"
You mentioned that "the sessions folder is a sibling of public_html" so I'm assuming that public_html is actually at the top-level of your filesystem. This would be unusual, though. Are you sure there is not more to the path? (You can double check by running pwd -P while in the directory, if you're using a UNIX-like system. You'll get back the full path to the directory.)
You also don't need a semicolon. That semicolon makes me a little wary, though: are you adding that configuration to your php.ini file? It's not something you'd add to just any piece of PHP code.
If you don't have access to php.ini and still need to change the save path, see session_save_path in the manual.

PHP - uploading to dir outside docroot

I have nginx+php-fastcgi running on my server and I"m trying to allow a php script in /var/www/contest to upload to a non-public directory located at /var/www/private/uploads.
I've tried changing the include path in php.ini but all I get is "No input file specified." when I try to view the page in /contest that uploads the pics.
your php script will run as some user. give that user write access to /var/www/private/uploads.
At first, check your upload_tmp_dir in PHP_INI system and set to right path.
Check write permissions for it.
Use move_uploaded_file to store files manually in right place.

Can you help me locate PHP session files?

I have a default configuration of xampp (LAMP) on a windows system, I have been googleing and reading stackflow for an hour but I can not find where php session data is saved, I would like to locate a session file and look at it.
Some sites say windows usually stores it here C:\windows\tmp\ but I was unable to find it there or anywhere else.
Do you know where sessions are saved
by default?f
Do you know what kind name and file?
extension they might would have?
session_save_path() - they have no extension, they are long string UID named files.
To find the "for sure" location, do the following:
Boot up a cmd prompt
Run php --ini and find the loaded configuration file
Open the config file and search for 'session.save_path'
That's the path your session files should be saved to.
This assumes that session.save_handler is set to 'files', of course, and isn't overridden anywhere in your code.
By default, it's probably "C:\WINDOWS\Temp". The filenames are generally prefixed with sess_, and do not have an extension.
Edit: Other posters are correct in using session_save_path() to find the path as well. That's probably a more foolproof method, in case there's differences between your CLI configuration and your web configuration. I'll hand out some +1's. :D
I find this command the easiest:
php -i | grep session.save_path
CTRL + F (windows Find)... search your XAMPP dir for files modified today (by date)...
Make a php test page. If you haven't done this before simply save the following as a .php file
<?php phpinfo(); ?>
Look for session_save_path under the session section.
If it is set, this should tell you your session path.
You can find where the sessions are stored for the current configuration by calling session_save_path() - this corresponds to the configuration setting session.save_handler as zombat says. The files I think are named by prefixing the session id with 'sess_'
Find Session files in Linux machine
Copy the session cookie from your browser (press F12 and tab to cookies field)
Use grep command with your session cookie value, It will show you the session file name
grep -ir "d79c67d3615b5d208680d51c1c023a6301437715444"
On my xampp session files are directly in "xampp/tmp" location.
Session files starts with prefix "sess_" and then hexadecimal hash.

Categories