简体   繁体   中英

php session problem

i'm having a very weird session problem under php: (works perfectly locally but not on my internet-server)

the problem:

  • i'm loading a page - i'm defining a php session via jQuery $.post in an external php script
  • i'm refreshing the page - session is still there
  • i'm loading a different page - the session is gone (empty)

there's no unset or anything which might reset/clear the session. i'm using a global php include for the header which triggers session_start();

any ideas? thanks

Try setting your cookie parameters to allow the domain to work across subdomains:

$params = session_get_cookie_params();
session_set_cookie_params($params['lifetime'], $params['path'], '.example.org');

Where example.org is your domain name.

Then before printing anything to screen start your session :

session_start();

On every page/resource you wish to be able access session data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM