Welcome Guest, Not a member yet? Register   Sign In
Calling a function on each page
#1

[eluser]Grim[/eluser]
Hey all started using CI a few weeks ago, and is swapping out old code with it :-) But a small snag I've hit is that before I used to have a PHP file called startsession.php which is called on every page to start the session and set vars if there is cookies available.
Code:
<?php
  session_start();

  // If the session vars aren't set, try to set them with a cookie
  if (!isset($_SESSION['user_id'])) {
    if (isset($_COOKIE['user_id']) && isset($_COOKIE['username'])) {
      $_SESSION['user_id'] = $_COOKIE['user_id'];
      $_SESSION['username'] = $_COOKIE['username'];
    }
  }
?>

So I have a controller named auth and have a function called auto_login which does the same thing but how do I call it on every page ?

Sorry If its a little redundant :blank:
Thanks In Advance :-)


Messages In This Thread
Calling a function on each page - by El Forum - 09-14-2012, 04:48 AM
Calling a function on each page - by El Forum - 09-14-2012, 04:57 AM
Calling a function on each page - by El Forum - 09-16-2012, 06:14 AM



Theme © iAndrew 2016 - Forum software by © MyBB