php - Codeigniter user tracking for visitors -
I am working on the Codeigniter site and implement the User Tracking Functionality for Visitors Trying (not registered user)
I want to track every page's redirects (IP address, from-page, to-page, time-stamp) and as I want to track only the temporary user, let me also To find out whether the account exists or not, access the database or not. My question is where do I have to write my code, so that the codiginator automatically checks before each redirect (keep in mind, that place should have the right to access the database or session).
Checking in each control file will be very redundant code and I do not think the HTACS file can do this.
- Thanks
There are several ways to do this:
< P> To create a support file, say "code: trackuser_helper.php folder in helpers. Create a function for tracking this file ( trackUser ()
). Next, type this file under config / autoload.php
: / * | -------------------------------------------------- ----------------- | Automatic Load Helper Files | -------------------------------------------------- ----------------- | Prototype: | | $ Autoload ['helper'] = array ('url', 'file'); * / $ Autoload ['assist'] = array ('trackujar'); // Ignore the '_helper.php' section of the file name
Now you can just call trackUser ()
in each controller. Provided by
config / hooks.php >>
Using the gone
hook
is my second option, / code> as:
$ hook ['pre_controller'] [] = array ('class' = & 'MyClass', 'Function' = & gt; 'MyFoncation', 'FileName' = & gt; Myclass.php ',' FilePath '= & gt; Hook', 'Params' => Array ( 'Ultimate 1', 'Ultimate 2', 'Etc.'));
The array index is associated with the name of that particular hook point you want to use. The hook point in the above example is pre_controller. A list of hook points has been found below. The following items should be defined in your Associate hook array:
1.Class - The name of the class you want to invite If you prefer to use a procedural function instead of a class, Leave this item blank.
2.Function - The name of the function that you want to call is the filename filename in which your class / function is
3. File Path - The name of the directory with your script. Note: Your script should be located in a directory in your Applications folder, so the file path is relative to that folder. For example, if your script is located in the application / hook, then you will simply use the hook as your filespace. If your script is located in application / hooks / utilities, then you will use hooks / utilities as your own file path. No trailing slash
4. Paragraph - A parameter that you want to pass to your script. This item is optional
It specifies which function call you want to execute before each controller load, in this way, you can use trackuser ()
in each controller < There is no need to add / code>. These hooks may be
pre_controller
or post_controller
. You can read more about the hook at
Comments
Post a Comment