0

I do an AJAX call to login my TYPO3 Users. Everything doing well. I also write some session values. After successfull login i have this session:

array(10) {
    ["loggedin"]=>
          int(1)
    ["user"]=>
          string(15) "Thomas Helmrich"
    ["kdnr"]=>
          string(3) "N/A"
    ["email"]=>
          string(15) "Thomas Helmrich"
    ["bereich"]=>
          string(3) "all"
    ["name"]=>
          string(0) ""
    ["intern"]=>
          int(1)
    ["nickid"]=>
          string(4) "4734"
    ["chatadmin"]=>
          int(1)
    ["spezialforum"]=>
          int(0)
}

but after the redirect like e.g.

header("Status: 301 Moved Permanently");
header("Location:".$redirect_url);
exit();

The Values are null

array(14) {
  ["loggedin"]=>
  NULL
  ["user"]=>
  NULL
  ["password"]=>
  NULL
  ["kdnr"]=>
  NULL
  ["email"]=>
  NULL
  ["bereich"]=>
  NULL
  ["name"]=>
  NULL
  ["chatadmin"]=>
  NULL
}

I currently don´t know why the values get null´d

Thanks

7
  • possible duplicate of stackoverflow.com/questions/17242346/… Commented Apr 2, 2014 at 14:00
  • 1
    have you used session_start() on the top of every page that you want to get the session values. Commented Apr 2, 2014 at 14:01
  • why are you setting header("Status: 301 Moved Permanently") ? Commented Apr 2, 2014 at 14:01
  • yes, i´m using session_start(); on top of the page. Commented Apr 2, 2014 at 14:02
  • my problem is not to have a NULL Session - but the Session VALUES are null. if i output session it outputs still the keys etc. but the values are null. Commented Apr 2, 2014 at 14:14

2 Answers 2

1

Session ID is not passed with Location header even if session.use_trans_sid is enabled. It must by passed manually using SID constant.

From: http://www.php.net/manual/en/function.header.php last note.

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

Comments

0

Try something like this (add Session-ID to the URL):

header("Status: 302 Found");
header("Location:".$redirect_url.'?'.session_name().'='.session_id());
exit();

This is only necessary if your client don't allow cookies.

BUT: Really have to make your redirection "permanently"? Maybe, a 302 do it better ...?

2 Comments

i do this rederict just for debuggin. i output it in my console. adding session_name and session_id doensn´t help - all values still NULL. It seems like it doesn´t have problems on finding the Session, the session itself exists with the keys - but the values are null.
OK. The session-id of the request is used by your server to locate a local sessionfile at the servers filesystem. This sessionfile contains the sessiondata. So check if your server uses another sessionfile for the targeturl. Have the redirected URL another (sub)domain then the Source-URL?

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.