SitePoint Sponsor

User Tag List

Results 1 to 18 of 18

Thread: session problem

  1. #1
    SitePoint Zealot dizyn's Avatar
    Join Date
    Apr 2006
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    session problem

    Hi

    I have sub domains on my site and i wanted to use one session across subdomains but i can't.. I am using following code but it's not working

    Can anyone tell what's the reason??

    Here is my code:

    PHP Code:
    session_set_cookie_params(3600,'/','.domain.com'); 

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Are you making that call in every single file that uses sessions and before you call session_start()?

  3. #3
    SitePoint Zealot dizyn's Avatar
    Join Date
    Apr 2006
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes call in on every page... 100% sure

    Can you please what i need to enable in httpd config fie or php.ini file?

    Thank you!!

  4. #4
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can anyone tell what's the reason??
    There is one.
    Debugging is his name. Most valuable programmer's friend.
    IF programmer smart enough to do many necessary things.

    Does it work for single domain?
    Does it send session cookie to the browser?
    Does browser send it back?
    Same for multiple domains?
    Does it work with passing session id manually?

    Does .domain.com reflect actual domain's name?
    Does all subdomains share same server?

  5. #5
    SitePoint Zealot dizyn's Avatar
    Join Date
    Apr 2006
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Does it work for single domain? Yes
    Does it send session cookie to the browser? Yes
    Does browser send it back? Yes
    Same for multiple domains? It does not work of multiple sub domains
    Does it work with passing session id manually? nope

    Does .domain.com reflect actual domain's name? Yes
    Does all subdomains share same server? Yes

    Thank you

  6. #6
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what is session save path for both subdomains?
    are you sure browser sends session cookie to the subdomain?
    are session id's equal on both domain and subdomain?

  7. #7
    SitePoint Zealot dizyn's Avatar
    Join Date
    Apr 2006
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's saving at /

    Here my phpinfo file

    http://www.cmela.com/zz.php

    Thank you for reply

  8. #8
    SitePoint Zealot dizyn's Avatar
    Join Date
    Apr 2006
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
        session_set_cookie_params(3600,'/','.domain.com');
        
    session_start(); 
    This is my current code... I have domains like

    community.domain.com
    shops.domain.com
    test.domains.com
    beta.domains.com

    I wanted to keep the session on all the domains


    Please check phpinfo at: http://www.cmela.com/zz.php

  9. #9
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    test.domains.com - is it typo or different domain?
    you can keep session for the one 2nd level domain, which set in the session_set_cookie_params()
    if you have other domains, you need cross-domain authorization system

  10. #10
    SitePoint Zealot dizyn's Avatar
    Join Date
    Apr 2006
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes type

    These are the domains i have on my main domain

    community.domain.com
    shops.domain.com
    test.domain.com
    beta.domain.com

    you can keep session for the one 2nd level domain [Can you please explain 2nd level?]

    if you have other domains, you need cross-domain authorization system [Can you please tell me how this can be done?]

    Thank you for reply.

    -dizyn

  11. #11
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    domain levels count from right to left
    in the community.domain.com com is the 1st level, domain is 2nd and community is 3rd. and so on.

    now to the cookies again.
    what exact cookie server does send to the browser, when your script starts a session?
    what exact cooike browser does send back?

  12. #12
    SitePoint Zealot dizyn's Avatar
    Join Date
    Apr 2006
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you don't mind can you please tell me which function cab be used to catch cookie that server send to browser and which function can be used to catch cookie browser send back?


    Thank you

  13. #13
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can use firefox plugin named LiveHTTPHeaders as well as many other HTTP headers sniffers.
    To see HTTP headers sent by server and browser and cookie and set-cookie among them

  14. #14
    Dinah-Moe Humm mudshark's Avatar
    Join Date
    Dec 2003
    Posts
    1,072
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have a look at session_name - from the manual:
    you MUST use session_name() first if you want to use session_set_cookie_params()

  15. #15
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is NOT from manual. It's a comment from someone who have no clue.

  16. #16
    SitePoint Zealot dizyn's Avatar
    Join Date
    Apr 2006
    Posts
    181
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it's send same session as it is receiving...

    I think problem is with settings of php or apache

  17. #17
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it's send same session as it is receiving...
    for the same subdomain or for the different ones?
    what are parameters of the server's cookie?

  18. #18
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think problem is with settings of php or apache
    Yes.
    May be.
    But there are thousands of settings.
    So, we have to find out which one.

    It is much like surgery. First we detect what leg broken and next take it off. Not contrary.


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
  •