Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP session warning in Windows IIS

Tags:

php

session

iis-8

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.

like image 739
CGA Avatar asked Aug 25 '16 09:08

CGA


People also ask

Why Session_start () is used in PHP?

session_start() creates a session or resumes the current one based on a session identifier passed via a GET or POST request, or passed via a cookie. When session_start() is called or when a session auto starts, PHP will call the open and read session save handlers.

What is PHP $_ session?

PHP $_SESSION is an associative array that contains all session variables. It is used to set and get session variable values. Example: Store information.

Is PHP session stored on server?

The PHP session which is accessible via the global variable $_SESSION is stored on the server as files by default. Also the reference to it (called session_id ) is stored on client side as browser cookies.

What is PHP session and how it works?

The browser sends a request to the server. PHP responds by sending a unique token that identifies the current session. This is known as the session ID. In all subsequent requests, the browser sends the session ID to say, "Hey, it's me again." All other data related to the session is stored on the web server.


3 Answers

As already stated by other, there is a chance that

  1. Either the C:\temp\phpsessions directory doesn't exist,Or
  2. Else IIS_IUSRS Read/Write Permission is missing in C:\Windows\Temp

there is no problem with your browser.

like image 100
Nitish shah Avatar answered Oct 06 '22 06:10

Nitish shah


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.

like image 22
serverSentinel Avatar answered Oct 06 '22 05:10

serverSentinel


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");
like image 42
Rakesh Sojitra Avatar answered Oct 06 '22 07:10

Rakesh Sojitra