SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Dec 2007
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with sessions after ISP moved my site to new server

    Hello,

    I'm having some sessions problems after my ISP moved my site to a new server, supposedly setup the same. The problem appears to be browser-specific as well, which I don't quite understand.

    First, my site uses sessions to login, this has been broken since they moved the site.

    My ISP has set up a test page at http://launchcomplex.com/loggedin_test1.php. When I hit this page in IE 6 (where it sets some session vars) and then hit the "header redirect" button, sessions seem to work fine. If I try it in Firefox/Opera, I get a new session id on the redirected page. My ISP reports sessions are working for IE as well, though I imagine they're using IE7 or perhaps even 8.

    Everything was working fine on my site before my ISP moved it and while they've been very helpful in responding, they're at a loss as to why it's broken. A couple of other of my sites with them were broken along with the move, but they have been resolved by server tweaks...Does anyone have any ideas what's going on?

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    before calling session_start(), call
    PHP Code:
    ini_set('session.cookie_domain''.launchcomplex.com'); 
    Notice the leading .
    This tells the browser the cookie should be shared with all subdomains. You will need to do this on all pages which call session_start(), or you can just set this in php.ini or .htaccess

  3. #3
    SitePoint Zealot
    Join Date
    Dec 2007
    Posts
    120
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Would that explain why the sessions work for IE and not other browsers? That's what I can't figure out, it seems like it'd work for everyone or no one.

  4. #4
    SitePoint Evangelist Tapan's Avatar
    Join Date
    May 2005
    Location
    India
    Posts
    556
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi,

    Try this:

    Code:
    @ini_set ("session.use_cookies", 1);
    @ini_set ("session.use_trans_sid", 0);
    session_start();
    $PHPSESSID = session_id();
    Put this on top of every php page. And then try the sessions.

    Thanks.

  5. #5
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by magenta placenta View Post
    Would that explain why the sessions work for IE and not other browsers? That's what I can't figure out, it seems like it'd work for everyone or no one.
    Browsers have different policies on how they treat cookies. Their behavior can also be modified through configuration of browser settings, so you cannot always expect identical behavior.


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
  •