Welcome Guest, Not a member yet? Register   Sign In
Admin for more than one site?

Hope I am putting this question in the right place.

As some of you know I have been working on several websites for one client. Now I am building an admin system for them to handle all the site. I have seen several posts where you can switch config or database files by using the domain your on. I am not able to do that. The admin will be on one domain. All the sites are hosted on the same server so I am able to connect to all the databases from one domain.

They all have the same database structure just different data.

There are 4 total databases.

main <-- holds the users and other internal stuff

in my database.php file (config folder) I have set up 4 groups

default (main)

Here is how it is working so far.

User goes to the admin, the default / main database loads.
During login the code checks to see what the last site was they were working on and sets a session var using set_userdata with that value.

Now logged in, the user sees a select menu with the current site (set in the session from the main db on login)

When they change the selector to a different site, i use ajax to change the session var and update the db. Doing so i use
and it is working fine.

The page reloads and the new selection shows and the session var is set to the new site / database.

Now on the pages where i pull information / edit / add etc.. i use the following code

$editdb = $this->session->userdata('editdb');
$CI =& get_instance();
$CI->$editdb = $this->load->database($editdb, TRUE);
$this->$editdb =& $CI->$editdb;

Then to make the sql calls i use

The issue comes when I want to use flash data. So say the user edits and item, well i want them to know the item was edited.
So i set flash data like so

$this->session->set_flashdata('msg','Update Success');
I then use the redirect with refresh set.

On the next page i check for the flashdata like so

But it never shows...

I am thinking it is because i have my sessions set to use the database. There are ways around it, i could use Cookies to pass the success or fail message but would like to keep everything consistent and well i seem to have no luck with the set cookie stuff in Codeigniter. My cookies never set...
If i use the php method of setcookie they work fine.

So I am guessing that what ever site is selected, that is the database the sessions are set to.

Any ideas on how to get my flash data to work across all the sites / databases?

Should i store the session localy and not in the database?

It is not a big cookie, userid(int), name, user type (int), logged in, selected site.

Thanks in advance.

Ok guess i should have tried that before asking...

I changed my sessions to NOT use the database and now my flash data is working fine.

Theme © iAndrew 2016 - Forum software by © MyBB