Sessions and www prefix.
Moderator: General Moderators
Sessions and www prefix.
I noticed that when I set session variables on my site without the www prefix and then type in the prefix the session variables don't apply.
If you know what I mean then my question is: Is there a way let these variables exist in both instances of the URI?
If you know what I mean then my question is: Is there a way let these variables exist in both instances of the URI?
- Kieran Huggins
- DevNet Master
- Posts: 3635
- Joined: Wed Dec 06, 2006 4:14 pm
- Location: Toronto, Canada
- Contact:
In your php.ini file you will find a line that reads something like:
; The domain for which the cookie is valid.
session.cookie_domain =
Add your domain prefixed with a . and don't forget to restart your webserver afterwards. eg:
; The domain for which the cookie is valid.
session.cookie_domain = .foo.com
; The domain for which the cookie is valid.
session.cookie_domain =
Add your domain prefixed with a . and don't forget to restart your webserver afterwards. eg:
; The domain for which the cookie is valid.
session.cookie_domain = .foo.com
If you dont have access to php.ini, you can achieve this by putting the below line before initializing session (session_start())
for more info visit http://www.php.net/manual/en/ref.sessio ... kie-domain
Remember you can change most of the values of php.ini with ini_set
Code: Select all
ini_set ( 'session.cookie_domain', '.foo.com' );Remember you can change most of the values of php.ini with ini_set
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
It is php's configuration file.
http://php.net/ini
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
make a blank php file, and add .. it will show you the location of your php.ini. If your on a shared server, most likely you won' have access to your php.ini and would have to consult your hosting provider to request changes.
Code: Select all
phpinfo()I have this on my hosting providers help center (godaddy.com):
I think this basically means that you can create your own and supply it to the server to your root directory, not edit the mandatory php.ini.
Is an initialization file the php.ini (does ini stand for initialization)? I assume.Godaddy wrote:Custom PHP 4 and PHP 5 initialization files You can now customize your site by creating PHP initialization files in the root of your site to manage form, server, and environmental variables, server-side cookies, temporary directories, error display, and error logging.
I think this basically means that you can create your own and supply it to the server to your root directory, not edit the mandatory php.ini.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact: