I have an issue with login session. Basically the flow is like this:
- user creates account and defines a username;
- user logins using url ‘http://[username].website.com’
- (coded in php & mysql, using session cookie)
My problem is: when trying to directly login from the index page ‘www.website.com’ I don’t manage to get my user logged to his URL http://username.website.com
/// EDIT ///
Let say i have opened url “www.example.com” and created a session variable in this url. Now i want to access that session variable in url “test.example.com”. How to do that? any solution welcomed
/// EDIT2 ///
In the top of every php file i have used the below code but my session variable was destroyed and i can’t access the session variable in another page. I have also set session.cookie_domain = “.website.com” on “php.ini” file.
ini_set('session.cookie_domain', '.website.com');
session_name(“sessionid”);
session_start();
As minaz mentioned in the comments, make sure that the cookie you’re setting on http://www.website.com is valid for domain-matching on “.website.com”.
If you’re still not sure whats happening, try playing around with wget (http://www.gnu.org/software/wget/) using –save-cookies, –load-cookies and –debug.