Welcome Guest, Not a member yet? Register   Sign In
problem :1 session for 2 login form
#1

[eluser]bang gojep[/eluser]
Code igniter has open my eyes for the fond of working using framework =)
but i'm still newbie, so i got this problem.

i duplicate a login form for a backend sytem. named them localhost/cms1/login and cms2/login

if i logged into cms1, and i open cms2. it goes directly to the menu without needing to log in again. they must use the same session file right?

how should i differentiate the session?

thank you very much for the help, sorry if this has been posted before. no hurt to ask right? =)

newbie greets!
#2

[eluser]bang gojep[/eluser]
any help would be much appreciated :coolsmirk:
#3

[eluser]WanWizard[/eluser]
The session is determined by the session_id stored in the applications session cookie.

The browser looks for a local cookie using the domain and the path of the page. So define your cookie parameters in config/config.php properly, and http://example.org/cms1 has a different cookie then http://example.org/cms2, and you will have two different sessions.

p.s. Note that this is a public forum with users just like you answering questions. We volunteer to do that. Don't start complaining if you don't get an answer in 5 minutes. Unless you want us to ignore you...
#4

[eluser]basty_dread[/eluser]
i dont know if this is the answer: you should have 2 session_id
1 for the cms1, and 1 for cms2

if you log in to cms1 you should use this session_id 1
if you log in to cms2 you should use this session_id 2

example:
CMS1
//validate first the log in
$sessiondata['cms1'] = 'admin';
set session 1 ex. $this->session->set_userdata($sessiondata);

CMS2
//validate first the log in
$sessiondata['cms2'] = 'users';
set session 1 ex. $this->session->set_userdata($sessiondata);



Hi Wan, i have a question.
using updated browser like opera, safari, or google chrome..
CI session was unable to create a cookie on this browsers? i dont know what happened but it works perfectly with FIrefox Browser.. any ideas?
#5

[eluser]bang gojep[/eluser]
Sorry for that WanWizard :cheese: it does look annoying.
I should look further to CI config files next time. You solved my problem, thx alot!
#6

[eluser]bang gojep[/eluser]
[quote author="basty_dread" date="1282916312"]i dont know if this is the answer: you should have 2 session_id
1 for the cms1, and 1 for cms2

if you log in to cms1 you should use this session_id 1
if you log in to cms2 you should use this session_id 2

example:
CMS1
//validate first the log in
$sessiondata['cms1'] = 'admin';
set session 1 ex. $this->session->set_userdata($sessiondata);

CMS2
//validate first the log in
$sessiondata['cms2'] = 'users';
set session 1 ex. $this->session->set_userdata($sessiondata);
[/quote]

my problem is solved, thanx for the help though :cheese:

Quote:Hi Wan, i have a question.
using updated browser like opera, safari, or google chrome..
CI session was unable to create a cookie on this browsers? i dont know what happened but it works perfectly with FIrefox Browser.. any ideas?

wow, i havent tried it on other browsers than Firefox. coz i dont think sessions handling would be much different between browsers. How bout it Wan?
#7

[eluser]WanWizard[/eluser]
[quote author="basty_dread" date="1282916312"]using updated browser like opera, safari, or google chrome..
CI session was unable to create a cookie on this browsers? i dont know what happened but it works perfectly with FIrefox Browser.. any ideas?[/quote]
The more recent or modern a browser is, the more strict the security settings are on cookies. That means that you have to configure your cookies very carefully and precise, otherwise the cookie will be rejected by the browser.

Most common problems:
- cookie names with an underscore
- cookie domain illegal (for example 'localhost', 'co.uk', or with illegal characters, like an underscore)
- cookie path empty or wrong

For the last two, I use this in my config/config.php:
Code:
/*
|--------------------------------------------------------------------------
| Determine The Website Base URL
|--------------------------------------------------------------------------
*/
if (isset($_SERVER['HTTP_HOST']))
{
    // we prefer the hostname
    $config['base_url'] = $_SERVER['HTTP_HOST'];
}
elseif (isset($_SERVER['SERVER_ADDR']))
{
    // no hostname? then use the IP address
    $config['base_url'] = $_SERVER['SERVER_ADDR'];
}
else
{
    // last resort
    $config['base_url'] = 'localhost';
}
$config['base_url'] = isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) == 'on' ? 'https' : 'http' . '://'. $config['base_url'];
$config['base_url'] .= isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] != '80' ? ( ':'.$_SERVER['SERVER_PORT'] ) : '';
$config['base_url'] .= str_replace(basename($_SERVER['SCRIPT_NAME']), '', $_SERVER['SCRIPT_NAME']);

/*
|--------------------------------------------------------------------------
| Default Cookie Related Variables
|--------------------------------------------------------------------------
*/
$config['sess_cookie_name']    = 'ExiteCMSid';
$config['cookie_prefix']        = "";

// determine the domain and the path from the base_url
$base_url_parts = parse_url($config['base_url']);
$config['cookie_domain']        = $base_url_parts['host'];
$config['cookie_path']            = $base_url_parts['path'];
unset($base_url_parts);
#8

[eluser]basty_dread[/eluser]
i checked my cookies on firefox... there are values like
session_id
ip_address
user_agent
and last_activity

do you think this values are invalid? i am just confuse. and could anyone tell the cookie size limit?
Thanks..
#9

[eluser]WanWizard[/eluser]
These are part of the cookie value, and not relevant, other than that it indicates you haven't encrypted the cookie, which you should as a security measure.

And yes, there is a cookie limit. The maximum size is 4Kb. Which you are never going to reach if you use database sessions.




Theme © iAndrew 2016 - Forum software by © MyBB