Magento session creation destroys other session variables - php

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.

Related

Sessions in CodeIgniter hinder each other

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');

CakePHP: Unable to find Auth data in $_SESSION

I'm doing some basic integration between a CakePHP app and some external code. I want the external code to know if a user is logged in. The external code does not load CakePHP, so thought I would access that data directly using $_SESSION, but when I dump it it's an empty array, even when I'm logged into CakePHP.
Am I missing something? Why isn't the session data from CakePHP showing up?
You might need to play with your session ids and session name variables to get your external code to load the CakePHP session information.
For example, you will almost certainly need this:
session_name('CAKEPHP');
and you might need to pass across the session id from Cake, and possibly set the session save path as well.
You can read http://bakery.cakephp.org/articles/admad/2009/09/02/how-to-bend-cakephp-s-session-handling-to-your-needs
It will examplain you how to bend your cakephp session according to your need.
OR
You can see one more link which will solve your problem Use cakephp session with two different domains
Hope these two links will solve your problem!

Session-and user information

Using codeigniter's session class, what is the equivalent function/properties of $_SESSION['username'] in which username is a database column name ? –
Also, when I direct log in user to another page how can I retain his state in session ? In native php session, I just issue "session_start(), then choose the column name to put in $_SESSION[columnNAME]", it automatically works then.
I store userinformation after getting it from DB as
$this->session->set_userdata("db_result",$result);
If sessions are enabled in codeigniter then they will autostart you don't need to tell them to start.
Everything else you ask is explained in the codeigniter documentation
http://codeigniter.com/user_guide/libraries/sessions.html
You can consider implementing session_start() in your hooks, so that it starts automatically. Probably this is what you need. You can check how to implement hooks in Codeigniter's Documentation.
I don't prefer using codeigniter's session. If you do not use the DB option for session, codeigniter saves it in $_COOKIE and all the information we save in the session is clear text.
Its a security risk, because any user and simply read those cookies and install it on his own browser, and the site will start to treat user as authenticated.
So I advice, you stick to traditional PHP Session handling, and as already said, execute session_start() in your hooks
(PS: session being saved in cookies was true as of Codeigniter v1.7.3, I don't know about the latest development.)

Session not maintaining for the first time

i am developing a e-commerce website. The user logs in and buy a product when he checkout the page will redirect to the payment gateway. After the payment is completed it will return back to my website. This is ok. But when it is returning back the session maintained in my website get lost. This happen only for the first time. If the user again logged in and checkout the process works good and the session is maintaining.
Why does the session lost for first time.
I used session_start() in all the pages..
I cannot find the solutions. Kindly help..
Why don't you use javascript? You can create cookie to store your incoming members data.
With Jquery and cookie plugin you can do this very easy, sure you must do login for member to create this data. Some useful links:
http://www.jquery.com/
http://plugins.jquery.com/project/Cookie
http://www.electrictoolbox.com/jquery-cookies/
Why does the session lost for first time.
That's hard to tell because there is not much information in your question.
Normally a session get's lost if the session identifier (or session ID in short) is not passed from one request (page) to the other.
Please see the PHP Manual how the session ID can be passed. You need to take care with your code, for example that the cookie is properly set. If the session cookie is not set, the session id will be gone and session_start will create a new session.

Where are MediaWiki's sessions set?

I have my own login system, and I want MediaWiki to share the same session. I'm trying to have my login system automatically login to my MediaWiki too which means I would probably have to share the same user database too.
Advice?
Not sure if this is exactly what you want, but we use LDAP Authentication.
The session is set in includes/GlobalFunctions.php. If you want to fake a user login to mediawiki after the user logs in to your system, you'll need to make sure that the cookie parameters match (e.g. the cookie URL must be the same); have a look at the arguments they use to construct it in the call to session_set_cookie_params.
Once you've got the session set up correctly, you'll need to load a user and inject it to the session so that when mediawiki goes to check if the user is logged in, it finds your injected user and goes right ahead. Look in includes/User.php, the User::loadFromSession call looks like a promising place to figure out what they expect to find there.
If you make changes directly to the MediaWiki source, you'll have a hard time upgrading to future versions of MediaWiki. It would be much better to use the existing authentication plugin framework:
http://www.mediawiki.org/wiki/AuthPlugin
You didn't specify what your existing login system is, but if you're lucky somebody has already built a plugin for it:
http://www.mediawiki.org/wiki/Category:User_identity_extensions

Categories