www.webdeveloper.com
Results 1 to 7 of 7

Thread: My site is unabled to keep cookies from PC of a my friend

Hybrid View

  1. #1
    Join Date
    Jan 2013
    Posts
    84

    Question My site is unabled to keep cookies from PC of a my friend

    I've created a login form and other pages that keeps informations about the login.
    All works fine on my pc and other my devices, but my friend with windows XP is unable to keep sessions from a page to another, either with firefox and chrome, while from his tablet all works fine
    I'm assured that firefox is setted to keep cookies from alla sites, same in Control Panel -> Privacy of windows XP

    I don't know what else i can do!
    My site have a tk extension, maybe it's part of the problem?

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,392
    Sometimes this can be caused by one user using the "www." subdomain and another not ("www.exmaple.com/index.php" versus "example.com/index.php"), while links on the page use one format or the other. Easiest way to avoid this is to specify the domain when setting the cookie to just use the domain with a leading dot, so that the cookie applies to any subdomain or no subdomain:
    PHP Code:
    setcookie('user'$user0'/''.example.com'); //note leading "." with domain 
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Jan 2013
    Posts
    84
    Quote Originally Posted by NogDog View Post
    PHP Code:
    setcookie('user'$user0'/''.example.com'); //note leading "." with domain 
    and in the case of sessions, what i should write?
    setcookie should be called after or before session_start() ?

  4. #4
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,392
    For sessions, if possible, you want to set session.cookie_domain in your php config. If that's not possible/practical, then each place where you call session_start(), you can add it there:
    PHP Code:
    <?php
    session_set_cookie_params 
    (0'/''.example.com'); // must be before session_start()
    session_start();
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  5. #5
    Join Date
    Jan 2013
    Posts
    84
    the
    PHP Code:
    setcookie('user'$user0'/''.example.com'); //note leading "." with domain 
    works fine on pc of my friend (the user variable is readable)
    While
    PHP Code:
    session_set_cookie_params (0'/''.exemple.com'); // 
    session_start(); 
    continued to no work!

    So, i deduce that it's not a cookie problem (else the first method would not have to work), but it's explicitly a problem with sessions
    Last edited by American horizo; 03-17-2014 at 03:13 PM.

  6. #6
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,392
    Just to make sure we don't miss anything obvious, I'll ask the (hopefully) silly question: you did change ".example.com" to your domain name, right?
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  7. #7
    Join Date
    Jan 2013
    Posts
    84
    yes!
    If you want to try, go to gametalking.tk/login.php and insert:
    Username: Tester
    Password: password

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles