SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2009
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy PHP 5 sessions sub-domain problem

    Hi, Im developing a large auction website with 5 sub-domains, my major problem is that once I login from either of the 5 sub-domains I cannot access secure pages in the other sub-domains because the session variables do not work across the sub-domains. This means that I have to login in every sub-domain to be able to access secure functions and pages. Does anyone have a solution for this. I have used the following code

    session_set_cookie_params(30 * 60, '/','.sokomart.co.ke');

    This works perfectly in my local host.

  2. #2
    PHP Guru lampcms.com's Avatar
    Join Date
    Jan 2009
    Posts
    921
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Add this to top of your script:
    ini_set('session.cookie_domain', '.sokomart.co.ke');

    Cookies will work for sub-domains then

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Make sure you're setting the cookie domain before session_start() is called. Make sure you always set it before starting a session, on every script.

    clear cookies and try again.


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
  •