无法在服务器中设置会话,在localhost中工作

I am setting user id to the session on login in my website.On echoing the session variable soon after being set, it is displayed.But after that iam redirecting this to another page where session is strated and then checked for the session.But it displays error message that undefined index user_id.This code is working in localhost,was working in server also.But now it displays error.Unable to login to the website due to the problem in setting session.

$_SESSION['user_id'] = $user_id;
header('location:home.php');

In home.php

include('session.php');

in session.php

session_save_path('include/session_store');
session_start();
if(!(isset($_SESSION['user_id'])))
{
header('location:signin.php');
}

On advise from fellow stackoverflow users ,I tried this.Created a test.php file.

session_save_path('include/session_store');
session_start();
$_SESSION['yahoo'] = 'yahoo';
header('location:test2.php');

in test2.php

session_save_path('include/session_store');
session_start();
echo $_SESSION['yahoo'];

Now in localhost yahoo is printed.But in server, blank screen is displayed.The session_store folder contain some 0kb files also.

make sure yout do session_save_path('include/session_store'); session_start(); on signin.php and also make sure include/session_store is writable

you said its working on,localhost, then definitely problem is include/session_store is not writable.

Do you have right permissions on include/session_store ? It has to be 777. You may print echo session_save_path() to ensure that the option is setted. And at last, without changing the save_path the session works correctly? Your server may have some redirecting rules (mod_proxy) that could have repercussion on your session.

If you have php 5.4 you could try to print session_status() http://www.php.net/manual/it/function.session-status.php