I'm making a CMS using CodeIgniter. I'm using modules to separate the admin part of the site from the normal site. I make use of session to store some data, this is working great but i got 1 problem.
When i login in the Admin panel it makes a session so I know I’m logged in. When I go to the normal site and return to admin and refresh my page I’m logged out. It seems like when I go to the normal site it first clears the session or it overwrite the old session. I think this comes because of the session name used by CodeIgniter.
now my question :p
Is it possible to set different session names for the admin module and the normal site?
I hope I have made myself clear
Best practice if you handle session with db in CI
yes it's possible please use seperate session for both and on logout unset seperate session what session you want to unset.
like you create session for front:-
$this->session->set_userdata('user_account_login',$data);
on logout you need :-
$this->session->unset_userdata('user_account_login');
same for admin but in different var :-
$this->session->set_userdata('admin_account_login',$data);
on logout you need :-
$this->session->unset_userdata('admin_account_login');
Related
I am using sessions to check if the user is logged in. In my project, there are some pages, where session check is not required i.e user can access it without logging in. How I disable session check on selective pages? Instead of writing say session_check on every page that needs session, i want to know if there is a way to implement no_session_check() on selected pages. As the number of pages that require session check are more than pages that do not work. I am using codeigniter. Thanks
First you created the session checking function in library file .. if u want session on that controller just call that library function..
Refer this link:
I have a user logged in admin panel(backend) and frontend of the joomla site. I checked the session table in DB and found that a session has been created for that user. I just deleted that row from DB and when I goto admin panel(backend), the user is logged out, which is correct.
But when I goto frontend of the site, the user is not logged out. So my question is "Is separate session maintained for frontend and backend for same user?" If it so then why I didn't find the 2 session rows in session table of DB? Is frontend session stored in separate table?
Also is there a way such that when I click on logout button, I logged out from both backend and frontend of the site?
I think this is due to the fact that removing the row from the #__session table does not fully clear the session. When manually logging out, the Session class is called and the session is destroyed, for example:
$session = JFactory::getSession();
$session->destroy();
Doing this also sets the session state to destroyed:
$this->_state = 'destroyed';
So you'll need to use PHP for this rather than removing tables from the database
The front and back ends are two separate and independent applications. So you can be logged into either or both and have separate sessions. It is possible to share a session also but that requires some work. What's odd to me is that you only saw one session in the table. Are you positive? Did you check the client value?
I am using PHP native session instead of CI session library.CI version ci-2.2.
When i login to admin, it sets the session.I can go to any next page which requires session.But when when i go to another page after that the session is lost.It works fine locally and on many other servers for which I use CI.
As an example.
I login to admin.It takes me to dashboard.Then i go to some listings page.It works fine.Thereafter I click on say some add new page , session is lost.
if any of your controller extends the admin controller make sure the session check is done on the admin controller itself.
so that any controller that extend it will inherit the check.
Hope this helps.
My CI application has been working fine.
On my localhost it works properly and on the live site, CI keeps generating sessions every time there is a page refresh.
I've updated the sessions table on database to accommodate longer user_agents.
What could be the cause of this?
on your form page, you isn't make a condition if session is null or if you have a session,
if the form refresh, it will looping to make a new session.
so that's the problem
and then, if you want to delete a session you can
$this->session->unset_userdata($yoursession);
don't make a cookie i think that's not secure but if you learn a secure programming i think i will be secure ^_^
I am using Mage::getSingleton("customer/session") to be able to login to Magento externally. Problem is, this seems to clear up other $_SESSION variables I have set.
How can I have the entire cake and be able to login to Magento plus setting normal SESSION-variables?
I assume this answer might apply to you also: Magento external login will not create session cookie
In essence try first creating the Magento session before you create the other session.
If that doesn't help you might need to provide additional code so a good answer can be supplied.