1

To avoid illegal use I check the login status at the beginning of the code. I do this as follows:

if (!isset($_SESSION['loggedin'])){
  header('Location:http://www.name.nl/prg/login.php');
  exit();
} 

This works. But if I use this code first it doesn't work.

ini_set('session.save_path',realpath(dirname($_SERVER['DOCUMENT_ROOT'])).'/name.nl/tmp');
session_start();
if (!isset($_SESSION['loggedin'])){
  header('Location:http://www.name.nl/prg/login.php');
  exit();
} 

Am I missing something? I looked for 2 days now, but can't find a reason/solution. It seems to me that the header function should work after ini_set and session_start. I mean it is common code?

1

2 Answers 2

1

Try this first: ini_set('session.save_path',realpath(dirname($_SERVER['DOCUMENT_ROOT']).'/name.nl/tmp'));

(Move parentheses)

Try looking here: http://php.net/manual/en/function.session-save-path.php

Not sure if this will help or not but it seems related to where your session folder is at and then pointing to the proper directory/folder in your code.

The solution that worked for them: ini_set('session.save_path',realpath(dirname($_SERVER['DOCUMENT_ROOT']) . '/../session'));

Your current session save:

ini_set('session.save_path',realpath(dirname($_SERVER['DOCUMENT_ROOT'])).'/name.nl/tmp');

Sign up to request clarification or add additional context in comments.

Comments

0

Well I found the cause. I had an "echo statement" before the header statement. After deleting this statement it works fine. Thx for your comment anyway!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.