Author Topic: Users getting logged-out (OR) state/city selections never load.  (Read 313 times)

maverick

  • Administrator
  • Veteran Member
  • *****
  • Posts: 2931
  • Karma: +210/-7
    • Maverick Webworks
Users getting logged-out (OR) state/city selections never load.
« on: September 24, 2016, 08:50:35 PM »
If you're experiencing one or both of the following issues:

1. When a user logs-in they get logged-out in a short period after navigating the site.

2. On search or join pages when selecting the country it continuously spins and the state/city selections never loads.

This is usually caused by how your site domain is defined.

During the install process if you defined your site's domain URL as www.mysite.com (with the www prefix) then that's what needs to be used when members visit and login to your site. If a member visits and logs into the site without including the www prefix, once they start navigating the site the URL will switch to the www prefix in their browser often causing them to get logged-out because sessions are not carried through or shared between www.mysite.com and mysite.com. Basically, www.mysite.com won't be recognized as being the same domain as mysite.com (without the www prefix).

The most recommended and common method to remedy the problem is to force either the www or non-www version of their site to display in the visitor's browser. It's been suggested that doing this can also be better for SEO. This can be accomplished by including a mod rewrite in your .htaccess file, which is located in the main root directory where you installed Etano.

Open your .htaccess file and include one of the following code options in the file (you can place it at the top of the file).

Option 1 - Force the www prefix to be used:
Code: [Select]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301,NC]

Option 2 - Force no www prefix to be used:
Code: [Select]
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.yoursite\.com [NC]
RewriteRule ^(.*)$ http://yoursite.com/$1 [L,R=301]

Note: Depending on your server's configuration you may have to also include the RewriteBase directive as shown below:
Code: [Select]
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301,NC]

Important -  The RewriteRule should be set to whatever you have set as the BASEURL in your includes/defines.inc.php file.

If you've chosen to use the RewriteRule for the www prefix to be used, then make sure line #7 is like this:
Code: [Select]
define('_BASEURL_','http://www.yoursite.com');// protocol required (http:// )
If you've chosen to use the RewriteRule without the www prefix to be used, then make sure line #7 is like this:
Code: [Select]
define('_BASEURL_','http://yoursite.com');// protocol required (http:// )
When your done it would be a good idea to clear your browser cache and cookies to ensure you're not using an old session cookie.

If the above mod rewrite doesn't work the issue could be with your host, possibly with server session timeout issues. You'll need to contact your host to look into it for you.

Fusion Responsive Template & Free Mods
http://www.maverickwebworks.com
DO NOT PM me asking for personal help. Post your problem or request in the forums so the entire community can contribute and benefit.