🔒 Closed Cookie vs session

GOOD TIPS?


  • Total voters
    3
Status
Not open for further replies.

RNA30

Fanatic
PHP:
<?php
   setcookie("cookie_name","cookie_value",time()+60,"/");

   echo $_COOKIE['cookie_name'];


   $_SESSION['session_name']="session_value";

   echo $_SESSION['session_name'];
?>

When you are using COOKIE, you can set the expiry of it. So that if the COOKIE did not meet the expiry you can access its value, even you open/close your browser. But when you are using SESSION you can't set the expiry of it and when you close your browser and open it again...the data you stored in session are lost. It will be deleted automatically when you left your browser.
 
T.S. curious lang ako, minsan tuwing nag visit ako ng mga websites tapos may nag pop-up na "this website using cookies" cancel / OK safe ba ito ?
 
T.S. curious lang ako, minsan tuwing nag visit ako ng mga websites tapos may nag pop-up na "this website using cookies" cancel / OK safe ba ito ?
Depende po sa site na nibi-visit nyo. Ang alam ko lang po kc ang Cookie ginanagamit para maretrieve ung data. Temporarily dito nila ini-store ung mga di naman gaanong complicated na data.
 
I think Cookie Expiry can only set up to 20 years, because I tried to set the cookie to set("cookie_name","cookie_value",time()+630720000,"/");...and it is still working but when I multiply it to 5 it gives me 36 years back or the cookie expiry set to 1981...
 
I think Cookie Expiry can only set up to 20 years, because I tried to set the cookie to set("cookie_name","cookie_value",time()+630720000,"/");...and it is still working but when I multiply it to 5 it gives me 36 years back or the cookie expiry set to 1981...
Ah, nice info po. Salamat sa pagshare.
 
Gyan ba sa Cookie naka save yung username at password? Kapag nag clear ako ng cookies mag logout na account ko?
 
Opinion lang po ano...ang cookie much better if ang user ay gumamit ng sarili nitong pc or any personal computing device used to connect the internet...kasi pwede ma store ang values ng any info ng user whether the browser is in execution or not...that is why may mga option ang mga website na "remember password"...yung session naman if you want your users to use their credential as long as they are using it or as long as users browser is open...

Nag cocoment lang para maka balik establish
 
Cookie VS Session

Depende po sa app na gagamitin or much specifically sa privacy ng page:
Cookie - kapag gusto mo maretain yung info or login status ng user sa specified time kahit iclose pa yung browser
Session - kapag gusto mo mawala yung logged in status kapag nagclose na ng browser
 
Status
Not open for further replies.

About this Thread

  • 11
    Replies
  • 1K
    Views
  • 6
    Participants
Last reply from:
bsmobile

Trending Topics

Online now

Members online
1,000
Guests online
1,415
Total visitors
2,415

Forum statistics

Threads
2,272,879
Posts
28,946,075
Members
1,236,451
Latest member
pakaw2555
Back
Top