Page 1 of 1
Sessions and www prefix.
Posted: Sat Mar 31, 2007 5:05 pm
by JellyFish
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?
Posted: Sun Apr 01, 2007 4:58 am
by Kieran Huggins
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
Posted: Sun Apr 01, 2007 7:09 am
by mentor
If you dont have access to php.ini, you can achieve this by putting the below line before initializing session (session_start())
Code: Select all
ini_set ( 'session.cookie_domain', '.foo.com' );
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
Posted: Sun Apr 01, 2007 1:09 pm
by JellyFish
Okay this is something I never really understood. What's the php.ini file?
Posted: Sun Apr 01, 2007 1:18 pm
by John Cartwright
It is php's configuration file.
http://php.net/ini
Posted: Sun Apr 01, 2007 1:59 pm
by JellyFish
How do I find it on my server?
Posted: Sun Apr 01, 2007 2:02 pm
by John Cartwright
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.
Posted: Sun Apr 01, 2007 2:18 pm
by JellyFish
I have this on my hosting providers help center (godaddy.com):
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.
Is an initialization file the php.ini (does ini stand for initialization)? I assume.
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.
Posted: Sun Apr 01, 2007 2:19 pm
by John Cartwright
You got it.
Posted: Sun Apr 01, 2007 3:45 pm
by JellyFish
Okay cool. So I found the php.ini file and what not. And I'm sure php.net has some articles on how it works.
Either ways, thanks guys.