• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting session status

Hello there

I'm not familiar with Codeigniter and i have bought script that is made using this. However i wanted to create pages in another language.

structure currently is


i just created subfolder to root and i have url structure as above working. But i'm unable to access sessions or is used logged in. I haven't ever used any frameworks so i really don't understand how this works. I have been reading docs about sessions and i don't know if i would need to check user status with cookies, $_SESSION or some db query.

Below is code from theme folder where i took view and header data for my language pages. There is this check with session('uid') that i cannot access from subfolders i created on root

<?php if (!session('uid')) {  ?>
    <a href="auth/login>">Login</a>
    <a href="auth/signup">Sign up</a>
    <?php }; ?>

<?php }else{?>
    <a href="Dashboard" >Dashboard</a>
<?php }?>

Seems so simple. If not session uid then show login and signup links and if session uid is created show dashboard link. What would i need to do to just get that session uid?

edit: Fixed code area

Finally i think i got it working. As i studied how this works i now have language folder in app/modules path. I removed it from root as i wasn't able to get session no matter what i tried.

I stripped some controller to bare minimum to just display my index file.


In my models there are all from another module but it seems not to do anything so i just leave those there for now. Maybe i could remove almost all those as well.

I added this folder to router files so it will add only language code at the end of url


And now i can just make a copy of that folder, rename files and add route for another language. I'm certain there would be much better way.

I noticed that this language page is not accessible if user is not logged in. Does someone have idea where i should do edit to allow access for everyone.

Can models file mess access as i havent made edits to it? It might been some user dashboard related page so it would be only accessible to users those are loggedin

Your model files are the files that access your database to pull in the business logic of
your application you better leave those alone. and changing any files in the application
is going to change the way it works.

To make it accessible to everyone you need to find the default controller and allow access
to everyone there. You can find the default controller by looking in the config/routes.php file
under the app or application folder CodeIgniter 3 it is application and CodeIgniter 4 it is app.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.