Jump to content

Php sessions across subdomains


phpsycho

Recommended Posts

Typically, a sub domain is just another directory in the your domains root (ie. domain.com/sub).  It's just DNS settings that make it accessible with the directory name infront of the domain (ie. sub.domain.com)

 

So with that in mind, handle sessions as you normally would.  Use session_start(); at the top of each page you are passing it to, and if in a shared hosting environment, consider storing session information in a database.

Okay so using this:

session_set_cookie_params(0, '/', '.example.com'); 
session_start(); 

 

Would do the trick? and thats secure, correct? I'm confused with the "set_cookie".. is that setting a cookie to your browser with session data in it? If so.. that can't be very secure I would imagine..  :shrug:

Secure: If TRUE cookie will only be sent over secure connections.

can you define "secure connection"?

 

Thanks again

ah alright, so just the id of the session, no other data. Feeling better about this lol.

 

Instead of using that code I posted, does setting this option: session.cookie_domain = .mydomain.com

in the php.ini file gunna do the same? Because it seems much more simpler to just do it that way.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.