codeigniter session destroy two different application - codeigniter

For example i am using two admin panel.Once I destroy all session value through one admin panel, another one admin session value also will destroyed . I am using unset and session_destroy for both admin panel. Is this any way to prevent one another

if you are using both panel in the same broswer. Then it will be destroyed. Using different browser might help. That's how session are made to work.

NOTE: Do not use session_destroy(), it destroys all data registered to a session.
So better to use unset(), it unset a given variable passed to the function. Also avoid the same session variable names.

use tow different sessions for admin panels and unset the particular admin session data instead of destroying all session data.

Related

Session is expired when working on two different projects at same time

I have two projects of sugarcrm installed on my local server, nothing wrong with that.
Now I start my first project i.e. sugarcrm in the browser, login with the credentials, and after that when I opened the second project i.e. demo_sugarcrm in the browser and login, my sugarcrm session is expired.
And same with the demo_sugarcrm also. Its session expired when I login to the sugarcrm
What is going on here, I have totally different database of both. they dont share anything except that both are on local sever.
I think adjusting unique_key is supposed to fix this, but as an alternative you could modify /etc/hosts such that 'sugarcrm' and 'demo_sugarcrm' hostnames both reference 127.0.0.1. Then you could visit http://sugarcrm and http://demo_sugarcrm. I'm sure any shared cookie mayhem would go away at that point since the browser would consider these to be distinct sites.
I believe that if you edit config.php and change the unique_key variable to be different between the two instances then you shouldn't get kicked out anymore.

How to make seperate SESSION for different URLs?

Hey guys I'm new to PHP.
I have a login page where I m setting some SESSION and logging in to view my pages.
I have one more login page where I m setting different SESSION values and logging in.
Now on loggin to first page I am able to view pages but when I login with page2 in new tab , page1 starts using SESSION values of page2..
How can I seperate these SESSIONS??
All opened tabs of your browser uses the same session. You need to use different names for your session variables

How to keep session unchanged in codeigniter?

I'm trying to create a shopping cart by storing the cart in a table in a database, instead of using the built-in CI cart class. I use sessionID to identify one visitor from another. But I found that the sessionID is changing for a period of time, even the visitor doesn't close the browser.
Is this a normal behavior of CI to renew the sessionID for a short period of time? Is there a way to make it unchanged until the visitor close the browser?
Thank you at advance.
Also, make sure in your config file you have cookie_prefix set.. see bottom of: http://ellislab.com/codeigniter/user_guide/libraries/sessions.html
If your session is contstantly being reset using the CI Session library, make sure the cookie domain is set to something like:
$config['cookie_domain'] = '.mysite.com'; // the . is for a wildcard subdomain

keeping login sessions with cakephp view caching

I use view caching in my cakephp based cms with generates the cached views for frontend usage.
The frontend checks whether a user is logged or not to show edit options. It works without the view caching enabled, but when enabled it loses the session.
I've put the session code in no cache tags (index.ctp), but there's no session available
<!--nocache-->
$_SESSION['Auth']['User']['username'];
<!--/nocache-->
How can keep the login session when using view caching?
The anwser is to use the cakephp session helper instead of the native php $_SESSION variable
<!--nocache-->
$this->session->read('Auth.user.name');
<!--/nocache-->

Access cakephp session (auth) from outside cakephp

I have a CakePHP website with its own login system using the Auth component. I would like to know if the following is possible:
A user has logged in and is navigating the website. At one point, he can click a link that opens an external php file. With external I mean that it could be in another folder of the same server, but outside the CakePHP app folders.
The "tricky" thing (for me) is to only show the contents of that php file if the user is logged in (to prevent someone without an account accessing those contents). I can't use Auth there because I'm "outside" Cake... I don't know if maybe using $_SESSION, but I don't know how...
Is this even possible? And yes, the php has to be outside the CakePHP app folder system.
Any ideas?
I'll add you also need to set session name to "CAKEPHP" using
session_name('CAKEPHP')
just before your external app session_start() otherwise you could not apply Kashif Khan suggested solution :)
Cheers,
Yes you can access the cakephp SESSION outside cakephp folder. try this session variable
$_SESSION['Auth']
if it exists then check for user here
$_SESSION['Auth']['User']
This is not working in Cakephp3. After calling
session_name("CAKEPHP");
session_start();
Application session is expiring.

Resources