Session lost after redirect in php

Hi

My session was lost when i m redirect to another domain and came to my domain. how to fix this ?

ex:

header(“location:”.example.com);

after getting result from the example.com , i could not access my session values it was lost.

Thanks

session_write_close should be what you’re looking for.
Use session_write_close before redirecting.

i have used but no change it behave like same

Did you use the function before or after your header function as you add it after the header the session won’t be able to store itself.

i have to redirect different domain
forexample

from IANA — Example domains to [url=http://www.example2.com]example2.com

when return back example2.com to www.example .com , my session was lost and create new session id. how to resolve it.

Maybe this setting needs to be tweaked:

PHP: Runtime Configuration - Manual

Cheers,
Alex

can you tell which one is better for this ? i didnt do anything in firefox,but in other browser start session automatically ,previous session was lost

I’m sorry but I am not sure I understand your question.

If your session is lost when switching sub-domains, it’s possibly due to the configuration options I linked to above. If your trying to persist a session across root domains, you will need to pass along the session ID with the URI.

Cheers,
Alex

i want to send some data from www.mydomain.com to ww.example.com. after that www.example.com send data to www.mydomain.com.

when result came back from example.com my session data are lost and create new session id . how to keep my session when redirect to another domain.