2 Replies - 217 Views - Last Post: 29 November 2012 - 10:02 PM

#1 hwoarang69  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 171
  • Joined: 23-October 12

get the name of cookies user loged in

Posted 29 November 2012 - 08:01 PM

let say i create session in login page. here session is on id and username.


    $_SESSION["id"] = $id;
    $_SESSION["username"] = $username_p;


now to see who loged in i can do this


    $user_name_s = $_SESSION['username'];  //has the name of who is loged in






now how do i do this with cookies? how can i get the name of user who is loged in here. (not using sessions)



    setcookie("id", $id, time()+172800); 
    setcookie("username", $username_p, time()+172800); //seconds - 2 days 


Is This A Good Question/Topic? 0
  • +

Replies To: get the name of cookies user loged in

#2 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3710
  • View blog
  • Posts: 5,958
  • Joined: 08-June 10

Re: get the name of cookies user loged in

Posted 29 November 2012 - 08:56 PM

You can use the $_COOKIE super-global in almost exactly the same way you use the $_SESSION super-global. Only difference is that new cookies are set via the setcookie function, rather than being assigned directly to the array. Also, new cookies do not immediately appear in the $_COOKIE super-global. They will only exist in that array after being sent to the client, and then sent back in a new request.

Read all about it in the manual:
PHP: Cookies - Manual
Was This Post Helpful? 0
  • +
  • -

#3 hwoarang69  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 171
  • Joined: 23-October 12

Re: get the name of cookies user loged in

Posted 29 November 2012 - 10:02 PM

thanks

This post has been edited by hwoarang69: 29 November 2012 - 10:06 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1