SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    598
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sessions across subdomain

    I am using PHPAnthology's sessions and logging them in a Mysql Database... Im trying to keep the user logged in across subdomains ie... user logs in on subdomain1.mydomain.com and then clicks on a link to subdomain2.mydomain.com. How can I keep the user logged it. I have the database working correctly. Currently it logs a session for each subdomain and the user must log in twice.

    Is there a way to keep them logged in?

  2. #2
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    Boston
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    I have never heard of that session manager before, is there a url link to it?


    I think what you will need to do, is set the cookie domain to the domain name ie: your_site.com and not to the full VHOST sub.your_site.com! This should be a config option in the program some where!

    J!

  3. #3
    SitePoint Evangelist
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    598
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually Im programming this app myself...

    The program or partial code im using is from Harry Fuecks PHP Anthology Book.
    Ive set up my database and app to record the session in the database. So now when I login on subdomain it get a session_id and data that gets logged. When I click on subdomain2 i have to relogin. This second login creates a second session_id in the table but the data logged is the exact same. Somehow there has to be a way to keep this person logged in since the data is the same. Do I need to pass something in the URL? maybe recheck if they've logged in each page? ideas?

  4. #4
    SitePoint Enthusiast
    Join Date
    Nov 2004
    Location
    Boston
    Posts
    25
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi

    Ok so your just using a active session cookie and not creating one?

    You will have to control this in your script! Because if you don't PHP will base the cookie domain on the requested URL or what is set in your PHP.INI under (session.cookie_path, session.cookie_domain). You should not every allow control that you can manage in your script be managed by the defaults PHP uses or what is in your PHP.INI file. Do you know how to set a cookie at login and assign a cookie hash that (refrences the login session <- as to allow for auto logins between visits)?? If you don't, could you show me your session code so I can show you how to implement one into your script!


    J!

  5. #5
    SitePoint Evangelist
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    598
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hum...the session code is spread out in a few class files as per the anthology code.

    basically it creates a record in the DB with session_id, data and data includes the usrname, password, login_hash

  6. #6
    SitePoint Evangelist
    Join Date
    Oct 2001
    Location
    Texas
    Posts
    598
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I guess my question is... if I can get the session ID across domains with either a url or cookie.... how do i reestablish the session already having the session id so they dont have to relogin?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •