drupal 7 anonymous user sessions not storing - php

I'm currently building a website using Drupal and I use an external php script to do the login. When the login is successful, the session variables are supposed to be updated with the user data.
While I was developing that script, I kept it only visible to administrator users, but now that I have it available to everyone, as an anonymous user, the session variables are updated on the php script, but the pages in drupal can't read them. But the problem only happens as an anonymous user. As an administrator the script works great
Any idea how to solve this?

I had the same issue.
When you know that the user is logged with your php script, log him with drupal. It's kind of synchronization.
For that, you can use: user_external_login_register

Related

TYPO3 a few questions about felogin

i would like to redirect to a page outside from the typo3. is this possible because i donĀ“t find a input form to do that?
I have an external PHP application. This application may only be called after a successful login. Is it possible to bind the login data from felogin to a session that I can use in my PHP application? I need the login information in my PHP application. I would like to use the felogin logout mechanism in my external PHP application. Is that possible?
Regards
MS-Tech
Not by default.
The easiest way I can think of, if the external PHP application runs on the same domain, is to alter the PHP application to read the TYPO3 frontend user cookie (fe_typo_user) and get session (fe_sessions table) and frontend user (fe_users table) data from the database.
The cleanest way I can think of is to rewrite the external PHP application as a TYPO3 extension, but I'm assuming this would be too much work.
As for the log out, you can link to the TYPO3 login page and add ?logintype=logout to the URL.

Website access control

I'm currently working on adding a login system to an old website. Unfortunately, I'm new to web developments and can not find answers for the following questions:
1. How can I check if a user is logged in or not before serving his http requests. I do understand that in pho we just add session_start() follow by some checking statements. But the website I'm working on is really big and can would be tedious to add session check statement in every page. so is there a way to check if a user is logged in before serving his/her request?
The server is using nginx and the website is using php.
Thanks

Share active directory session Wordpress

We have several webapps based in Wordpress and Codeigniter, which are based on different servers but under the same domain (ie: intranet.something.local) and most of them use Active Directory login credentials.
For Wordpress, I'm using a plugin called Active Directory Integration to log in with these credentials and it's working perfectly after configuring openLDAP.
The thing is, our client asked us to have a single log on for every app, meaning that once I'm logged into Wordpress, I should be logged in when I go to another app, that uses the same login user and password.
Is there a possible way to do this? And if so, where should I start?
I believe, that is possible in multiple ways..
Setup Single Sign On in your apps
Use a script which automatically copies User data from a web app,
and then using that information creates user login to the other
apps..Idea is to let user register for one site, and based on that information, register him to other sites automatically
May be, some sort of Database sharing be possible, but that would be
really really a tough job, still Possible (I believe, in Computer
Science, nothing is impossible forever)
create a common cookie file and when user switches the app, use that
cookies to get the user login in between different apps

Cookie and session issues in php / mysql / wamp

I use wamp to develop on a windows 7 machine. For this app I have an admin area which tracks the admin username and encrypted password with $_SESSION and a cookie which keeps track of the randomly generated encryption key for the password.
I set the cookie like:
setcookie('key', $key, time()+7200, 'admin/');
The admin user verification is run on every admin page after the admin user has entered username and password details to login.
The directory structure of the site and the admin is:
localhost/mysite/
locahost/mysite/admin/
A session runs in the admin section, and a session also runs in the user interface of the front-end to keep track of chosen criteria for searches.
When I run long database queries in the admin area ie. multiple updates and inserts where each iteration requires a connection to an external API, I am unable to load the front-end user interface in the same browser ie. firefox until after the admin operation has completed. If I use a different browser ie. chrome , I am able to load the front-end of the site while running admin mysql functions with no problems.
I'd like to view the site while these operations are running, and use the same browser. It's a small problem, but I'd like to know how to get around it because I want to learn. I mean I could just tell myself that it doesn't matter because the site works fine when I open another browser, and the final user isn't going to be running admin operations while viewing the site anyway, so from that perspective it doesn't matter, but I am curious.
What is going on with the sessions and cookies that stops me from viewing the site whilst the admin operations are running? Is my question even a good one? Part of me thinks that it's a silly question because ultimately the site works perfectly well in a separate browser. Anyway, thank you for looking!
I think your session is being locked. On the page that takes a long time to run add this at the top: session_write_close(); that should fix it.

jQuery Mobile login handler

I started to develop a web application as a major project for my degree. Purpose of app is not important. My problem is handling the login. I have no problem with setting up login with jQuery mobile, that is actualy working pretty well. Problem is I'm handling login with php script through ajax and creating session in that process. So for checking if user is logged in or not I'd normaly use a php script, but in this case I can't. I need to keep using only client side for authentication. What would be the solution for this? Can I handle authentication with some native jQuery functions or do I need to write some JS scripts? If anyone have any solution please I don't need actual code, just best solution. Thank you
You can achieve this as long as login authentication is restricted to the device. What I mean is that user-id / password combination can be stored locally on the device. You may choose local file system storage for this. Here are the steps:
1) Make user register with uid/password
2) Check uid is existing in your local storage. If not register by writing it to local storage.
3) Later when user returns, validate login credentials against the local store.
I assume you're developing a native app with a mobile web framework. In this case you have two choices:
POST the login details out to a server somewhere, authenticate and return the session, allowing the user access. This will obviously require internet access, but will be more secure.
Store the credentials in local storage using JavaScript when the user signs up. Encrypt this value and compare against it when the user logs in.

Categories