Page 1 of 1

Sessions are losting in http://www but working in http://url

Posted: Sat Dec 06, 2008 5:40 am
by jeh
HI,

My project have multiple modules. I have one menu it contains all module tabs. Let us,

i login in one module is called 'XXX'. Next i am going to another module is

called 'YYY' by clicking menu. In this process session values are working in

'XXX' module. But in 'YYY' module session are losting if url alike

'http://WWW.myurl' but in 'http://myurl' session values are

working. How to solve this problem ? If u have any ideas please advice me.

Thank in advance,

Suman.

Re: Sessions are losting in http://www but working in http://url

Posted: Sat Dec 06, 2008 5:57 am
by requinix
Keep the same domain name. When you make links don't include the http://yoursite.com part, just the /path/to/file.php.

Re: Sessions are losting in http://www but working in http://url

Posted: Sat Dec 06, 2008 4:06 pm
by Chris Corbyn
Sounds like your cookie is being set at www. the domain, which does not include the non www version.

You best solution is NOT to support both domain.com and http://www.domain.com, but to redirect http://www.domain.com to just domain.co, or vice -versa.

In a .htaccess file, something like this:

Code: Select all

 RewriteEngine On
 
  RewriteMap lowercase int:tolower
 
  RewriteCond %{HTTP_HOST}    ^www\.(.+)                              [NC]
  RewriteRule ^/(.*)$         http://${lowercase:%1}/$1               [R=301,L]
 
Also (without taking this too seriously ;)): http://no-www.org/

Re: Sessions are losting in http://www but working in http://url

Posted: Sat Dec 06, 2008 5:50 pm
by Kieran Huggins
Your session is being saved to a specific subdomain - you can make your session available to all subdomains (including the root domain) by setting the cookie to ".domain.com" (notice the preceding dot?)

There are several ways to accomplish this... read: http://www.jontodd.com/2006/08/10/php-s ... e-domains/ for a few different methods.