Basically, in general web application with php we used to check session through calling php script in that particular html page.
But as I am working in Integration of application i.e. Angularjs and Laravel, I m not getting how can I achieve above said thing in this application.
Please guide me for this.
Thanks in Advance.
Sessions are handled by Laravel automatically. The session data is stored in cookies. It doesn't depend on your JS framework
If you want to check if the User has logged in, use this:
if (\Auth::check())
{
// The user is logged in...
}
Related
I'm using the laravel framework. In my case, I need to save the data (login or register for example) in remote database on cloud.
But the communications with database and laravel, I need to use a rest api.
I have a php class in laravel with functions (login function for example) and in this function I have created the connection logic to my remote rest API (send email and password).
Now, I made connection to remote database and check if the email and password exists and return back a message (if true then I return the view, false i show a error message).
Till this it works fine. But I have a problem. Because I am not using the laravel authentication mechanism in routes file. I am unable to use the middleware to prevent direct access to routes without login. What is the best way to add this security?
I need your help. Thanks a lot.
Regards
It is also possible to create a local useraccount, with the credentials of the account recieved from the API. On this way, you can load all the needed data in your website and also use the auth middleware.
There are multiple ways to do so, maybe you can create your own cookie and check it before any output.
I have a question. How to check user authentication in MVC app, which is loaded in iFrame ? The main app, wchich presentig iframe was written in PHP. Users are logged in PHP app.
What can I do, to check is the user was authenticated, and check about his name, id or something what I'll map in my app.
I'm an author of MVC app, but not a PHP app. Of course I have a contact with the PHP teamt, so I can ask them to set something (object, marker, variable) when tehy call my MVC.
Thanks for your help
You can have a common cookie between both the application or use a cookie created by php to know the user details and create one for your own asp.net mvc app. I have few similar link which may help
Stackoverflow ASPNET-PHP
I have a ruby on rails application and now i have to include a php app along this with the single sign in. I want to login and pass the session value to the php code so that it can check if the user is authenticated. But i do not know how to access the session that is passed from rails app in php? please help me.
Or tell me if i can use some other way to check if the user is authenticated in php from rails app. I am struggling with this for quiet a few hours. Any help is appreciated.
I am writing an application in CodeIgniter and I have concluded that it's best to write two applications. One for back office and one for client use.
I would like to have just one login screen. It will be in the back office application but if a client user logs in then I want to redirect to the client app and create a session there. The database user table stores the user type i.e. client or admin.
I have come up with the following solution. As I want to this the correct way I said i'd run it by you guys to see what ye think.
User logs into admin CI app.
Admin CI app verifies user and determines type. If admin then go ahead and create session etc.
If the user is a client then MD5(user_ip+timestamp OR make a secure token some other way) and store in a token field (user_table) in DB.
redirect the user to the client admin via a login page. The paramters would be the token and username. The login function would then go to that user in the database and verify the token.
On successful authorization of token the CI client app would start a session and let the user in.
This seems like a very long winded method. Ideally there would be a way to start a session for one CI app from another?
Any ideas?
Thanks.
Once you've verified admin or client, I would use the CodeIgniter session class with the ci_sessions table in your database.
http://codeigniter.com/user_guide/libraries/sessions.html
Then to distinguish users from client or employee add a variable to the session.
$this->session->set_userdata('user_type', 'client');
Then just use that if ever you need it.
I would go about making 2 applications under HMVC (Hierarchical-Model-View-Controller) framework.
HMVC CodeIgniter Tutorial
Then you can go about using same sessions under multiple applications, as well as use the same models for user management, etc..
HMVC helps you modularize your applications, thus if you want to add more applications in the future, you can easily do that, passing over same sessions and such.
I answered your question in a bigger scope, one central login with 2 apps, best should be done with HMVC.
:)
Might wanna check out BackEndPro for CodeIgniter, could save you a lot of time.
Includes:
User Authentication with registration & account activation
User Permissions by using ACL (Access Control Lists)
Admin GUI backend for editing Site-wide Preferences
Built on Matchbox (for Modular development)
Asset Library (optimize, cache, and load JS & CSS)
ReCAPTCHA
Status messages (info/success/warning/error messages for the user)
I am currently wondering how a centralized page authenticator could be achieved. Can anyone suggest a neat algorithm for me? What I intend to achieve is to make my backend administrator pages session protected without writing a piece of session checking code to each of my pages that I want protected. I currently do something like this:
login page -> if right credentials : set session -> if view protected page without session : reject else : permit
Any best practices (or a better method) on/than this?
I would not so much want to suggest an algorithm, but a library/framework instead.
If your application has a single entry point, that is the place to call your session management library/framework. For example with the Zend Framework you can initiate your session in the bootstrap. The only thing left is to authenticate a session in the login controller.
If you're architecting a PHP app that has multiple entry points you will go crazy trying to copy and paste all this code. Look into using a real MVC framework.
I use Zend_Controller to route my pageviews in situations like this.
Once you architect your app in that way, it becomes simple to add some code to the predispatch() method of your restricted controllers to do authentication and redirect to a login page if it is not found or is invalid.