![]() |
Starting Session Problem
Im having a small problem with a login script. When a user logs in the session is not stored, however if they log in again their session is started. I do not understand why, it is not every single time but almost every time.
On my login page it works something like this after the user hits the submit button. PHP Code:
PHP Code:
|
1 Attachment(s)
I'm not sure where the problem exists within that code. Perhaps there is a flaw in your logic somewhere. Take a peak at the simple session code I have written for you. See if that helps you.
|
Thanks, I will take a look at that in the morning and see what I can figure out from it.
|
Well I finally figured it out.
The problem came down to a www and no www problem. Not a problem with my sessions. It would work if the user came in to the page with www in front of the url because my form was forwarding to the homepage with a www. however someone without www on the url would log in and then be forwarded to a www and they would no longer be logged in unless they took the www back off. One hell of an annoying bug, that I finally figured out on accident. Just thought I would let others know if they are having the same problems as well. |
Thanks. Isn't that down to the cookie path though? You set the path that is valid for the cookie in the fourth argument in
setcookie. Alternatively, however, you could simply forward all www to non-www, and vice versa. That's the best way, I would say, because it's also better for SEO. |
Ye gonna have to take a look at doing that, that is with the .htaccess correct?
|
Yes, that's the one.
Code:
RewriteEngine On |
| All times are GMT. The time now is 05:21 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0