SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: Cookie Code?

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

    Cookie Code?

    Hi my site is using cookies like $_COOKIE['mysite_username'] but what is the code if they arnt logged in?

  2. #2
    SitePoint Zealot rain5017's Avatar
    Join Date
    Sep 2005
    Posts
    166
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    setcookie('mysite_username', $username, time()+3600,'', '');

  3. #3
    Non-Member
    Join Date
    Mar 2005
    Posts
    832
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    no i mean i got a page that says text if they are logged in but if they arnt logged it i want it to say different text but i dont know what the cookie code is if it isnt logged in

  4. #4
    SitePoint Zealot webox's Avatar
    Join Date
    Sep 2005
    Posts
    183
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    check to see if the cookie is there, for example
    Code:
    if (isset($_COOKIE['mysite_username']))
    {
    
          // Do whatever you need to do, once they are logged in
    
    }
    else
    {
    
          // Tell them that there not logged in
    
    }

  5. #5
    Non-Member
    Join Date
    Mar 2005
    Posts
    832
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i cant use else codes cause it interfers with my other code

  6. #6
    SitePoint Enthusiast Cborrow's Avatar
    Join Date
    Apr 2005
    Posts
    57
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php
    if(isset($_COOKIE['mysite_username'])) {
        
    //do the code for if they are logged in
    }
    if(!isset(
    $_COOKIE['mysite_username'])) {
      
    //do the code for if they are not logged in
    }
    ?>

  7. #7
    SitePoint Zealot Nova's Avatar
    Join Date
    Sep 2002
    Location
    Netherlands
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Tidal Wave
    i cant use else codes cause it interfers with my other code
    then read how it is done and translate it into your coding style....
    if you can't beat them call them cheaters

    www.phppatterns.nl


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
  •