PDA

View Full Version : What you think is causing this...



Protege
19-04-2009, 01:33 PM
I has a page and its located at

a: http://www.mypage.com/status.php

and I have another page

b: http://mypage.com/status.php

when I login on my login page

aa: http://www.mypage.com/login.php

page a:

http://www.mypage.com/status.php

says "logged in" (quote) however page b

http://mypage.com/status.php says "not logged in" (quote)

But if i login page bb

http://mypage.com/login.php

page b then says "logged in" (quote)

Both yes, use the same code (they're exactly the same page without www [vice-versa])

The code on the following "Status" page is this:



<?php require_once 'Includes/Core.inc.php';

if( $Core->Users->Logged_In() )
{
echo 'logged in';
}
else
{
echo 'not logged in';
}
Now what do you think is causing this occurrence? Some setting I haven't set right or something?

- Thanks in advance

James

Jxhn
19-04-2009, 01:45 PM
It's something to do with how the cookie's are set rather than the script to detect status.

Many websites redirect if the url doesn't begin with www..

Protege
19-04-2009, 01:49 PM
Yet Im not even using cookies at that point, its using a PHP session to check against a database.

I can fix the problem like you said but its the issue that im using flash to check Page.php and I rather not place a url in that like http://www.mypage.com/Page.php

I used the following code on my other hosting account (With cpanel etc) now im just using barebones VPS with LXadmin installed for apache/mail/etc

I was just guessing it was a setting that had to be set.

I'll go through the PHP/Apache settings and see what I find

DeejayMachoo$
19-04-2009, 02:03 PM
Do u need to start sessions?

Protege
19-04-2009, 02:04 PM
No thats init in the core.


SebastianJu
21-Aug-2008 08:41 (http://uk3.php.net/manual/en/book.session.php#85224) Cant believe this problem isnt described herein. I wondered why my session-variables lost their values when going from first site to second site. Both had a session_start();.

A session is working only on one domain. Subdomains dont use the Session of the maindomain. That means if someone comes to your site at yourdomain.com and the session is started there and then clicks a link where he is lead to www.yourdomain.com (http://www.yourdomain.com) then the old session isnt working there anymore. Because www. is a subdomain.

In the practice that will mean a lot of lost sessions only because webmasters dont know this behaviour. I have never read a word about this in manuals or somewhere...

The solution is to put this code before the first session_start();

ini_set("session.cookie_domain",substr($_SERVER[HTTP_HOST],3));

Now it works. At the second place of parameters has to come in ".yourdomain.com" (with a dot before). With that the subdomains will use the same session like the maindomain. In this example domainname taken from Server-variable.

Greetings!
Sebastian

Protege
19-04-2009, 03:23 PM
Fixed it with apache :(, now ive got to some how piggy back the session data the browser uses so flash is "logged in" oh fun

Thanks anyway.

Thai-Man-Land
19-04-2009, 04:06 PM
I think it's .htaccess


RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.mypage\.com [nc]
RewriteRule ^(.*)$ http://www.mypage.com/$1 [R=301,L

Want to hide these adverts? Register an account for free!