Re: Followup to session question / scope of session
| From: | Erik Price | Date: | Fri, 19 Jul 2002 19:03:43 +0000 |
| Subject: | Re: Followup to session question / scope of session | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-108560@lists.php.net to get a copy of this message | ||
On Friday, July 19, 2002, at 02:40 PM, Chad Day wrote:
If I refer to a script without the filename (http://www.online-leagues.com/my), Apache apparently interprets that as (http://online-leagues.com/my/look-for-the-index-file).This depends on your Apache configuration, and is pretty normal. Usually it will look for index.html first, then index.php, then index.shtml, or whatever order is specified in your httpd.conf file. You may be able to override this with a .htaccess file too.
Now, I could just rewrite all the URLs, but in the near future I want to be able to have http://my.online-leagues.com and http://calendar.online-leagues.com working and use data in those sessions. I'm not sure what cookies have to do with this, aside from passing along the session id.That's exactly what cookies have to do with this. By relying on the cookie to pass the session id, you can only maintain the session by making this cookie available to the server. Since a cookie is only readable by the domain which sets the cookie, you need to adjust the value of the "domain" attribute of the cookie so that it is readable by other subdomains. The easiest way to do that is to set the cookie's domain attribute to ".domain.com" which means "any subdomain of domain.com". Refer to this spec, it will help you understand: http://wp.netscape.com/newsref/std/cookie_spec.html Note I just found a quick article, which I haven't read, which may help you: http://www.phpbuilder.com/columns/chriskings20001128.php3
<? session_start(); $I_AM_A_NEW_VALID_USER = '1'; session_register("I_AM_A_NEW_VALID_USER"); echo "<a href=\"http://online-leagues.com/leagues/testdir/index.php?"; echo $PHPSESSID; echo "\">link</a>"; ?>What is the URL of this link? Look at it closely, it is missing something: <a href="http://online- leagues.com/leagues/testdir/index.php?XXXXXXX">link</a> You've specificed a GET variable name but no value. Try doing that again, but put the name "SID=" immediately before the $PHPSESSID value.
I apologize if I am missing something basic here / am not understanding.. I just don't know what I have to do to get my session to work across that entire domain.. I thought worst case, passing along the SID would work, but that doesn't seem to be working either.No big deal it just looks like you forgot to name the GET variable. Read up on that cookie stuff, it'll help you in the long run if you're serious about doing a lot of session work. Erik