php - Session won't start and server variables are incorrect

687

I am trying to start session this way:

session.auto_start = 1

I set it this way. The session doesn't start. I changed start in my php as the following:

ini_set("session.use_only_cookies",true); 
session_save_path(dirname(__file__)."/../User");

Basically, I dont see any file created in that folder.

Also when I do this:

$id=session_id();

I get$id=0;

Why all those mistakes happen?

161

Answer

Solution:

I am trying to start session this way:

session.auto_start()

Where and how do you do that? Not in code I hope? It's a php.ini setting, and if you want to enable it, you have to do it there.

I changes start in my php as the following:

  ini_set("session.use_only_cookies",true); 
  session_save_path(dirname(__file__)."/../User");

Basically, I dont see any file created in that folder.

Does the user as which PHP runs have permissions on that folder? Haven't you got your PHP files sorted in deeper folders, where "(directory)../User" doesn't exist? Have you tried echoing the path to see where it points? Have you tried manually writing a file there? What about usingrealpath()?

Also when I do this:

$id=session_id();

I get id=0;

That's a symptom. Your session doesn't start, so you can't get a session ID.

$os=$_SERVER['SERVER_SOFTWARE']; I am trying to get the operating system and I get nothing.

What do you get? Triedvar_dump($os)?

and when I try to do this: $browser= $_SERVER['HTTP_USER_AGENT']; I get weird browser.

Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2

That "Weird Browser" is Chrome 15. What's weird about that?

And please enable error reporting since I'm sure there'll be a few hints there.

People are also looking for solutions to the problem: Convert .doc to .html with google docs and php

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.