Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
579 views
in Technique[技术] by (71.8m points)

php - Session sharing between two CodeIgniter Applications

I have 2 codeigniter installs running on the same server.

the first app is : localhost/aa/index.php

second app is : localhost/aa/invoice/index.php

The second app is in the first app folder. In the live environment, they will be on the same domain. I am trying to get a single sign-on to work -- so, if i have userdata set in the aa application I should be able to verify it in the invoice folder also.

Is there a way to share the sessions.

As the folders will always be on the same domain, I am open to working with sessions outside the ci library(only php) also.

Edit : They show the same session id when they don't have any data. The moment I add some variables on one application, the other goes out of sync.

Also I have sessions being stored in the database(both applications share the same database.)

Please suggest.

Thanks! : )

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Codeigniter for some reason rolls its own session implementation rather than native PHP sessions.

http://codeigniter.com/user_guide/libraries/sessions.html

You get a choice of using:

  1. cookie storage (not ideal, small storage size, sensitive data in a cookie?).
  2. database sessions (persisted using session id cookie).
  3. Override and roll your own (to use native php sessions!)

Obviously you need to make sure your session identifier is configured correctly so both apps can read from the same session data. If using the database implementation, you need to make sure both apps can access the same DB.

To add to the complexity, if you choose to encrypt sessions, the salt used by the encryption class will also need to be the same in both apps, so either one is able to decrypt the shared session data.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...