PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, February 27, 2022

[FIXED] How do I catch cache for the user in CakePhp

 February 27, 2022     cache-control, cakephp, cakephp-3.0, php     No comments   

Issue

I dont really have much experience in cache controlling and CakePhp. I am not a regular programmer as well. I got a situation where if the user is visiting a site for a first time there will be a pop up appearing on the screen. If the user visited it before there wont be any popup.

As for checking the user is authentic, i can use

<?php if (empty($auth_user)) { ?>

//codes for popup modal

<?php } ?>

My question is, is that possible to implement some logic like this to catch the cache or check wheather the tmp file is empty or not?


Solution

No there is not good ways to catch cache, But there only one way COOKIES to do it but it will be terminated and work newly as user just delete them in his browser.

As php is an server side scripting language
If you not want to save cookie then use LOCALSTORAGE but in JAVASCRIPT
1.COOKIE(Cookies can be stored via PHP)

setcookie(nameOfCookie, valueOfCookie, expireTimeOfCookie, pathOfCookie);

Simple insert "/" in pathOfCookie
Getting COOKIE in PHP

<?php
if(isset($_COOKIE[$nameOfCookie])) {
    //User already visited your site.
} else {
   //Use doesn't visited your site yet.
   //Show POPUP here. And set cookie here (In Else Condition).
}
?>

Keep in mind that if the expiryTimeOfCookie passes it will expiry. And not exist (Time In Seconds For 1 Day = 86400



Answered By - Ahmed Ali
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing