Session is lost when using ( or not using) www in the URL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rizwan6feb
    New Member
    • Jul 2007
    • 108

    Session is lost when using ( or not using) www in the URL

    Hi everyone, I am having a problem in with PHP sessions. Most of the URLs i haved used in PHP are in the form http://www.example.com i.e include www in the url. But if someone types http://example.com in the address bar of the browser and logs in, i redirect them to http://www.example.com/account.php their session is lost. How can i resolve this
    Last edited by Atli; Aug 7 '08, 06:52 PM. Reason: Replaced real URL with example.com
  • nathj
    Recognized Expert Contributor
    • May 2007
    • 937

    #2
    Can we see the code? My first guess, that there is a missing session_start() could be the thing to check but there may be something else going on.

    Post the code - remember to use code tags.

    Cheers
    nathj

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      Heya, rizwan6feb.

      My first guess is that your session cookie is restricted to the www subdomain.

      Look at your php.ini file's session cookie settings (http://php.net/manual/en/session.con....cookie_domain) and see if you need to adjust it (probably from '' to '.myweb.com').

      Comment

      • rizwan6feb
        New Member
        • Jul 2007
        • 108

        #4
        Originally posted by pbmods
        Heya, rizwan6feb.

        My first guess is that your session cookie is restricted to the www subdomain.

        Look at your php.ini file's session cookie settings (http://php.net/manual/en/session.con....cookie_domain) and see if you need to adjust it (probably from '' to '.myweb.com').

        Thanks, sorry for late response

        session.cookie_ domain variable is set to 'no value'

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          Try setting it to '.example.com' (replace "example.co m" with your domain). Then restart Apache, clear your cookies and try again.

          Comment

          • rizwan6feb
            New Member
            • Jul 2007
            • 108

            #6
            But i am using more than 1 domains

            Comment

            • pbmods
              Recognized Expert Expert
              • Apr 2007
              • 5821

              #7
              Originally posted by rizwan6feb
              But i am using more than 1 domains
              More than one domain pointing to the same site, or are there multiple sites on your box?

              Comment

              • rizwan6feb
                New Member
                • Jul 2007
                • 108

                #8
                More than one domains on a single box

                Comment

                Working...