Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warning: session_start(): Failed to read session data: user (path:) #1

Closed
tennom opened this issue Feb 8, 2018 · 6 comments
Closed

Comments

@tennom
Copy link

tennom commented Feb 8, 2018

I couldn't make this code work with both the latest stable PHP7.2.2 and PHP7.1.X.

I also had the --enable-fpm with compilations. It showed this error Warning: session_start(): Failed to read session data: user (path:).
I also tried to override default session manager with implements \SessionHandlerInterface which returned same error. Then I started doubting some compatibility issues of 7.2 and 7.1 with session_set_save_handler, but can't find any proof and not much time dig in as of now.

I could make it work with PHP7.0.X. builds with no problem!

@wintstar
Copy link

Check this

replace

	public function _read($id){
		// Set query
		$this->db->query('SELECT data FROM sessions WHERE id = :id');
		// Bind the Id
		$this->db->bind(':id', $id);
		// Attempt execution
		// If successful
		if($this->db->execute()){
		// Save returned row
		$row = $this->db->single();
		// Return the data
		return $row['data'];
		}else{
		// Return an empty string
		return '';
		}
	}

with this

	public function _read($id){
		// Set query
		$this->db->query('SELECT data FROM sessions WHERE id = :id');
		// Bind the Id
		$this->db->bind(':id', $id);
		// Attempt execution
		// If successful
		if($this->db->execute()){
			// Save returned row
			$row = $this->db->single();
			// Return the data
			if (is_null($row['data'])) {
				return '';
			}
			return $row['data'];
		}
	}

works with php 7.1

@tennom
Copy link
Author

tennom commented Feb 25, 2018

Thanks for the solution. I learned that php 7.1 and above strictly requires the session read to return a string and not even a null value. That's why the error was raised. This code also raised an error when using registration-ID function. Because it follows a different action cycle in 7.1 and above I suspect, like read->close->read->write... I will post my code when i return to that problem soon.

@jtangu
Copy link

jtangu commented Jan 7, 2019

Hi I'm having the same issue with migrating from PHP 7.0 to 7.1

I'm trying to find which file has the above stated code to update the function _read. Sorry I'm new.

@tennom
Copy link
Author

tennom commented Jan 7, 2019

I used a different approach. I don't think wintstar's code solves the issue.

@jtangu
Copy link

jtangu commented Jan 7, 2019 via email

@arslannawaz
Copy link

I used a different approach. I don't think wintstar's code solves the issue.

Kindly share your approach here? wintstar's code do not works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants