Jump to content

Recommended Posts

I made a similar but way more advance function php - page to manage with all the session stuff but I was wondering if i do somethign like include('includes/functions_session.php'); at the top of index.php or login.php if it will do everythign fine since its in a function. Ontop of that note will isset($_SESSION['someName']) and !(isset($_SESSION['someName'])) work with conditional things like IF statments

 

<?php
/********************************************************
* functions_session.php
*
* Deals with everything involving sessions
********************************************************/

//
// Start the session and if this is first time running then setup
// default values into what variables will later be used
//
function sessionStart()
{
    if(start_session())
    {
        if((!isset($_SESSION['Managed'])) || ($_SESSION['Manged'] === false))
        {
            //
            // Update user's cache so it will expire in one hour
            //
            cacheUpdate(60);

            //
            // Assign default values to session array
            //
            $_SESSION['LoggedIn'] = 0;
            $_SESSION['UserID'] = 1;
            $_SESSION['AuthID'] = 0;
            $_SESSION['Error'] = 'None';
            $_SESSION['Managed'] = true;
        }
    }
}

//
// Update the amount of time that the session variable will be autodeleted
// if for some reason no value is provided set a default time of 60 minutes
//
function cacheUpdate($time = 60)
{
    session_cache_expire($time);
}

?>

 

Thank you so much for your time! :)

 

  - tsilenzio

Link to comment
https://forums.phpfreaks.com/topic/62785-solved-help-session-managment/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.