Welcome Guest, Not a member yet? Register   Sign In
session error
#1

[eluser]elmne[/eluser]
I tried to use a session by specifying in the php.ini file a location for session.save_path

When i tried to load a view, i got the following error

Quote:A PHP Error was encountered
Severity: Warning

Message: session_start() [function.session-start]: open(/tmp\sess_s6r7b45cn1gjj6io82vsv87v22, O_RDWR) failed: No such file or directory (2)

Filename: libraries/Session.php

Line Number: 47

On line number 47, i have the following

Code:
// Sessions, start your engines!
        ini_set("session.gc_maxlifetime", $this->sess_expiration);
        session_start();



What's the cause of the error?
#2

[eluser]CI_avatar[/eluser]
If im correct. This error refers to PHP Issue not in codeigniter, because session in codeigniter has nothing to do with $_SESSION variable, session in codeigniter are save id $_COOKIE. no need to set session_start if you use Session Library.

Please ask help in php.net, i hope you can gather more information with your concern.
#3

[eluser]CI_avatar[/eluser]
If im correct, this problem does not refer to CI but in PHP. CI Session has nothing to do with $_SESSION variable, CI sessions are save in $_COOKIE (i know it sounds confusing but CI works that way).

Please go to php.net, i hope you can gather more information.
#4

[eluser]elmne[/eluser]
The session i'm referring to is based on Codeigniter's Hybrid Session.

When the error is generated, it refers to line 47 which is in the session.php in the libraries as shown below.

This error happened before i edited the php.ini file, what i should then have asked is this, if information is saved in a cookie, why is it that when i go to the next page, session values are no longer present?

In trying to resolve it, one of the things that was suggested was to check the session path but since you say that is immaterial since codeigniter uses cookies, then why does codeigniter's hybrid session not show the session values when i move to a successive page?

Code:
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
    Native / Database hybrid
    Code Igniter
    Citrusmedia - Matthew Lymer
*/


class CI_Session
{
    var $sess_table_name            = '';
    var $sess_expiration            = 7200;
    var $sess_match_ip                = FALSE;
    var $sess_match_useragent        = TRUE;
    var $sess_time_to_update        = 300;
    var $encryption_key                = '';
    var $flashdata_key                 = 'flash';
    var $time_reference                = 'time';
    var $gc_probability                = 5;
    var $userdata                    = array();
    var $CI;
    var $now;

    /**
     * Session Constructor
     *
     * The constructor runs the session routines automatically
     * whenever the class is instantiated.
     */
    function CI_Session($params = array())
    {                
        log_message('debug', "Session Class Initialized");

        // Set the super object to a local variable for use throughout the class
        $this->CI =& get_instance();

        // Set all the session preferences, which can either be set
        // manually via the $params array above or via the config file
        foreach (array('sess_table_name', 'sess_expiration', 'sess_match_ip', 'sess_match_useragent', 'sess_time_to_update', 'time_reference', 'encryption_key') as $key)
        {
            $this->$key = (isset($params[$key])) ? $params[$key] : $this->CI->config->item($key);
        }

        // Sessions, start your engines!
        ini_set("session.gc_maxlifetime", $this->sess_expiration);
        session_start();
        
        // Load the string helper so we can use the strip_slashes() function
        $this->CI->load->helper('string');

        // Are we using a database?  If so, load it
        if( !$this->sess_table_name ) {
            die('Session class database table name not configured');
        }
        
        $this->CI->load->database();

        // Set the "now" time.  Can either be GMT or server time, based on the
        // config prefs.  We use this to set the "last activity" time
        $this->now = $this->_get_time();

        // Set the session length. If the session expiration is
        // set to zero we'll set the expiration two years from now.
        if ($this->sess_expiration == 0)
        {
            $this->sess_expiration = (60*60*24*365*2);
        }

        // Run the Session routine. If a session doesn't exist we'll
        // create a new one.  If it does, we'll update it.
        if ( ! $this->sess_read())
        {
            $this->sess_create();
        }
        else
        {
            $this->sess_update();
        }

        // Delete 'old' flashdata (from last request)
           $this->_flashdata_sweep();

        // Mark all new flashdata as old (data will be deleted before next request)
           $this->_flashdata_mark();

        // Delete expired sessions if necessary
        $this->_sess_gc();

        log_message('debug', "Session routines successfully run");
    }

    // --------------------------------------------------------------------

    /**
     * Fetch the current session data if it exists
     *
     * @access    public
     * @return    bool
     */
    function sess_read()
    {
        // Unserialize the session array
        // $session = $this->_unserialize($session);
        
        $session = array();
        
        foreach( array('session_id', 'ip_address', 'user_agent', 'last_activity') as $key )
        {
            if( !isset($_SESSION[$key]) ) {
                $this->sess_destroy();
                return FALSE;
            }
            
            $session[$key] = $_SESSION[$key];
        }    
            
        // Is the session current?
        if (($session['last_activity'] + $this->sess_expiration) < $this->now)
        {
            $this->sess_destroy();
            return FALSE;
        }

        // Does the IP Match?
        if ($this->sess_match_ip == TRUE AND $session['ip_address'] != $this->CI->input->ip_address())
        {
            $this->sess_destroy();
            return FALSE;
        }

        // Does the User Agent Match?
        if ($this->sess_match_useragent == TRUE AND trim($session['user_agent']) != trim(substr($this->CI->input->user_agent(), 0, 50)))
        {
            $this->sess_destroy();
            return FALSE;
        }

        $this->CI->db->where('session_id', $session['session_id']);

        if ($this->sess_match_ip == TRUE)
        {
            $this->CI->db->where('ip_address', $session['ip_address']);
        }

        if ($this->sess_match_useragent == TRUE)
        {
            $this->CI->db->where('user_agent', $session['user_agent']);
        }

        $query = $this->CI->db->get($this->sess_table_name);
#5

[eluser]danmontgomery[/eluser]
http://www.google.com/search?q=session_s...+directory

http://php.net/manual/en/function.session-start.php

Quote:If while testing locally on your Windows machine you get many warnigns like:

Warning: session_start()... failed: No such file or directory
Warning: session_start()...: Cannot send session cache limiter - headers already sent
etc.

you need to configure properly the session.save_path in your php.ini file.

Set session.save_path to an existing folder on your PC.
For example: session.save_path="C:\Temp";
#6

[eluser]elmne[/eluser]
[quote author="noctrum" date="1277518684"]http://www.google.com/search?q=session_s...+directory

http://php.net/manual/en/function.session-start.php

Quote:If while testing locally on your Windows machine you get many warnigns like:

Warning: session_start()... failed: No such file or directory
Warning: session_start()...: Cannot send session cache limiter - headers already sent
etc.

you need to configure properly the session.save_path in your php.ini file.

Set session.save_path to an existing folder on your PC.
For example: session.save_path="C:\Temp";
[/quote]


Thanks for the info, i was able to resolve the error and now sessions can be written to the given path.

But codeigniter still fails to show the values of the session to the successive page.

It shows values on the first page but when i click another page where the same session values should still be displayed, they don't show up, yet they are placed into the session using the an array and the set_userdata session function

Code:
$newdata = array(
        'arrival_date' => $this->input->post('arrival_date'),
        'departure_date' => $this->input->post('departure_date')
        );
        
        $this->session->set_userdata($newdata);




Theme © iAndrew 2016 - Forum software by © MyBB