CodeIgniter Forums
Get last 2 access urls - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Get last 2 access urls (/showthread.php?tid=561)



Get last 2 access urls - GrigoreMihai - 12-18-2014

Is there a way to get the last 2 urls a user access ?


RE: Get last 2 access urls - InsiteFX - 12-18-2014

PHP Code:
$_SERVER['HTTP_REFERER'


This will return the URL that you just came from, you can then save it to an array etc;


RE: Get last 2 access urls - GrigoreMihai - 12-18-2014

I found 1 way by using cookies .. not sure if that is the correct way ...


RE: Get last 2 access urls - boltsabre - 12-18-2014

Hi Grigore,

Yes, to store the last TWO urls you will need to use some kind of persistent storage mechanism. This could be cookies, or something else like in a database, or in "sessions" (which can be either cookie or database driven).

Keep in mind, anything in a cookie is pretty easy for someone else to sniff, so if your URLs contain sensitive information (which they shouldn't), such as a secret login code for example, then you are opening yourself up to a security risk.


RE: Get last 2 access urls - Rufnex - 12-18-2014

If you have a user who is logged in, you simple can track the urls he access and log it with a timestamp (table, logfile, ..).
If you have no login you do the same but theefore you have no personal data and of courese all anonymous users will be mixded together.


RE: Get last 2 access urls - libreteam_studio - 12-18-2014

store it in session, and it will be fine Smile


RE: Get last 2 access urls - apparasenal - 12-18-2014

(12-18-2014, 05:39 PM)libreteam_studio Wrote: store it in session, and it will be fine Smile


I agree with the rest. Store it in session and you will easily retrieve the last two urls.