By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,409 Members | 1,604 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,409 IT Pros & Developers. It's quick & easy.

Session dies after HEader redirect

P: n/a
BT3
I appreciate the links on the session variables. I had actually hit that
and finished the login and supporting pages. Thanks for everything.

I noticed that PHP.NET said to do a HEADER Location: for a client re-direct.
When I do that thoughm it seems either the session is destroyed, or the ID
is lost. If I set session variables, then do a Header redirect, the
variables are empty at the new page. While I *could* just say "You are now
logged in, click here to continue", tht sounds kind of silly to me. Any
other way?

bt3of4
Jul 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
BT3 wrote:
I appreciate the links on the session variables. I had actually hit that and finished the login and supporting pages. Thanks for everything.

I noticed that PHP.NET said to do a HEADER Location: for a client re-direct. When I do that thoughm it seems either the session is destroyed, or the ID is lost. If I set session variables, then do a Header redirect, the
variables are empty at the new page. While I *could* just say "You are now logged in, click here to continue", tht sounds kind of silly to me. Any other way?


This is known behaviour for non-cookie based sessions. Workaround:
append SID *manually*--but only for redirection.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #2

P: n/a
BT3
new problem.
I'm doing a session_start(); at the beginning of the script.
Towards the end of the script I'm setting up the redirection, but SID
doesn't return anything.

Bt3of4

"BT3" <ho******@epmctc.com> wrote in message
news:JMdfe.876$Db6.565@okepread05...
I appreciate the links on the session variables. I had actually hit that
and finished the login and supporting pages. Thanks for everything.

I noticed that PHP.NET said to do a HEADER Location: for a client re-direct. When I do that thoughm it seems either the session is destroyed, or the ID
is lost. If I set session variables, then do a Header redirect, the
variables are empty at the new page. While I *could* just say "You are now logged in, click here to continue", tht sounds kind of silly to me. Any
other way?

bt3of4

Jul 17 '05 #3

P: n/a
This needs to have a few configuration options changed...

Note that getting the sessionid MUST be called before session_start()
otherwise you will replace the current sessionid.

Therefore you should retrieve it as follows:

session_start();
//your code
session_write_close();
$sessid = session_id();

This way the session is closed and then you can retrieve the id :)

Mike
Jul 17 '05 #4

P: n/a
BT3 wrote:
new problem.
I'm doing a session_start(); at the beginning of the script.
Towards the end of the script I'm setting up the redirection, but SID
doesn't return anything.


That means, session id is not found in the query string. Constant
SID and session_id() function are different.

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.