View Single Post

  #5 (permalink)  
Old 06-24-2008
Jerry Stuckle
 
Posts: n/a
Default Re: Sessions under localhost

pek wrote:
> OK, I've been having this problem for quite some time but never until
> now I really needed a solution. I have never thought of a work around,
> so I really need your help. Sorry if this has been mentioned already.
> You can point me to the post and I'll gladly read. I googled this a
> lot but, first, most people have tutorials for sharing sessions in
> subdomains, and, second, I have no clue what keywords to use.
>
> I am currently developing two web sites in my localhost. The first one
> is http://localhost/pageone and the other http://localhost/pagetwo. I
> have a login script for each. The login script can either be session
> based (for temporary logins) or cookie based (for long term logins).
>
> When I login in one site, I create two session variables named user
> and key which store a user name and a random 128 characters string.
> The key is stored in the database and changes upon each login (a
> little security). After successfully logging in in pageone using
> sessions, I noticed that in pagetwo I am also logged in. So I added a
> session variable "domain" which I check on both pages to see if the
> session information is for the right page. Although this works, I
> found that now I can only be logged in in one page at a time. I am
> assuming that sessions are shared.
>
> Cookies can be set using the domain to avoid this. Is there anything
> similar with sessions? Is there a work around? I'm also assuming that
> this will not be the case if I buy a hosting and create different
> domains for each web page. Is this true?
>
> Thank you in advance.
> Panagiotis.
>


Your problem is the domain is the same for both - so the browser will
send the session cookie to either one. This will not occur on a "live"
site.

I'm assuming these will be two different sites when you upload them -
i.e. www.example.org and www.example.com.

If this is the case, you have another problem - you probably won't use
www.example1.com/page1 and www.example.com/page2 when you upload them.
So, set up your web host to handle two different sites, and change your
HOSTS file to reflect the two sites. You can find more information on
how to do this in alt.apache.configuration (assuming, of course, this is
an Apache server).

Then you will be duplicating the "live" environment - and possibly find
some bugs (i.e. with file paths) that you didn't know about before.


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Reply With Quote