SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: Cookie Question

  1. #1
    Non-Member bigrollerdave's Avatar
    Join Date
    Mar 2005
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Cookie Question

    Ok when a user on my site logs in it stores a login cookie with some info so when they return to the site they should still be logged in right? When they come to the site it appears they are not logged in unitll they click on a link or something it then appears they are logged in. Is their a way to make it so when they go to the site it appears logged in without clicking anything. I have the cache set to no cache and must revalidate

  2. #2
    SitePoint Addict
    Join Date
    Mar 2005
    Posts
    314
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bigrollerdave
    Ok when a user on my site logs in it stores a login cookie with some info so when they return to the site they should still be logged in right? When they come to the site it appears they are not logged in unitll they click on a link or something it then appears they are logged in. Is their a way to make it so when they go to the site it appears logged in without clicking anything. I have the cache set to no cache and must revalidate
    This is something to do with the "location" of your session_start() function in your scripts I believe. I had the exact same problem some time ago for an application we created. Perhaps you could do your cookie checkup functions before your session_start() function then assign your "sessions" directly after the session_start() from those cookies (before the first page is displayed to that user).

    I could dig up some code that handles this properly for you but before that why don't you post your code here for review? That would be much better than having myself or someone actually re-create the entire logic for you from scratch.

    Regards,
    Peter

  3. #3
    Non-Member bigrollerdave's Avatar
    Join Date
    Mar 2005
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <? session_start();
    $time=time();
     
    session_register('username');
    session_register('usrid');
    session_register('Sess_UserId');
    session_register('usrname');
    thats at the top of every page

  4. #4
    Non-Member bigrollerdave's Avatar
    Join Date
    Mar 2005
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if the link looks like this it logs me out or appears that way

    http://www.hotfaceoff.com/

    but if i take the www out it works fine ..i dont get it

  5. #5
    SitePoint Zealot
    Join Date
    Aug 2005
    Posts
    138
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  6. #6
    SitePoint Member
    Join Date
    Jun 2002
    Location
    Norway
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The session is not valid for both hotfaceoff.com and www.hotfaceoff.com. If they log in at hotfaceoff.com they will not be logged in at www.hotfaceoff.com.
    -xqus
    Your friend in the fight against everyday sanity.

  7. #7
    Non-Member bigrollerdave's Avatar
    Join Date
    Mar 2005
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bambolin
    Yeah i saw that yesterday it wasn't much help thoguh because im have problems with sessions i think not the actuall cookie

  8. #8
    Non-Member bigrollerdave's Avatar
    Join Date
    Mar 2005
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok i get what your saying xgus if i sign in at www.hotfaceoff.com/login.php my session will be with the www on it so if i go to hotfaceoff.com my session will be pointless is there any way to make the session work with the www and without?

  9. #9
    SitePoint Member
    Join Date
    Jun 2002
    Location
    Norway
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by bigrollerdave
    ok i get what your saying xgus if i sign in at www.hotfaceoff.com/login.php my session will be with the www on it so if i go to hotfaceoff.com my session will be pointless is there any way to make the session work with the www and without?
    You might try to manually set a cookie for the other domain with the session id. It might work. Or you can set the action in the login form to force them to one of them. Always.
    -xqus
    Your friend in the fight against everyday sanity.

  10. #10
    Non-Member bigrollerdave's Avatar
    Join Date
    Mar 2005
    Posts
    0
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by xqus
    You might try to manually set a cookie for the other domain with the session id. It might work. Or you can set the action in the login form to force them to one of them. Always.
    how would i do that?


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
  •