I'm hosting my PHP Yii application on AWS Elastic Beanstalk and hence using the database to store sessions. I've successfully implemented facebook login using Hybridauth on a shared hosting environment. When I host on Elastic Beanstalk facebook login gives the error:
"You cannot access this page directly"
The URL ends up as:
http://mydomain.com/hybridauth/default/callback?hauth.start=Facebook&hauth.time=1393106016
I've learnt from here that this is related to facebook calling back to the application but finding a different session. Endpoint.php then throws the error:
# Init Hybrid_Auth
try {
// Check if Hybrid_Auth session already exist
if ( ! isset( $_SESSION["HA::CONFIG"] ) ) {
header( "HTTP/1.0 404 Not Found" );
die( "You cannot access this page directly." );
}
How can I ensure facebook calls back to the same session and successfully signs in with hybridauth?
Its due to PHP SESSION name
If you have change session name in confing file of Yii. Then you have to use add this session_name('samar_v4'); in file protected/modules/user/vendors/hybridauth/Hybrid/Endpoint.php in starting of functoin authInit
Check your Facebook application's redirect URL. Facebook doesn't allow multiple redirect URLs. So each time you change your hosting/domain/address, you'll have to reconfigure the Facebook application's redirect URL or use a different set of credential.
Also your redirect URL should be something like this: http://mydomain.com/hybridauth/?hauth.done=Facebook
This worked for me as well:
"base_url" => "https://example.com/inc/hybridauth/",
I changed it to
"base_url" => "https://".$_SERVER['HTTP_HOST']."/inc/hybridauth/",
For me it worked on the main domain but not on a subdomain. I worked out it was the base_url in config.php that caused the error.
Instead of
"base_url" => "https://mydomain.com/inc/hybridauth/",
I changed it to
"base_url" => "https://".$_SERVER['HTTP_HOST']."/inc/hybridauth/",
Now it works anywhere I put it.
For anyone else struggling with this issue, and its not related to the www-domain registration issue, my problem had to do with not being able to write to the php session directory. Not sure how or when it was altered, but if you cannot write to /var/lib/php/5.5/session, hybridauth will not work.
As per the other answers, I believe this is a session problem, perhaps the session is started under the wrong domain and then cannot be re-fetched under the other domain.
I solved this by removing various ServerAlias settings from my development Apache config.
this 'caused' the error:
ServerName mydomain.com.au.localhost
ServerAlias www.mydomain.com.au.localhost
ServerAlias localhost.mydomain.com.au # << using this one
this fixed the error:
#ServerName mydomain.com.au.localhost
#ServerAlias www.mydomain.com.au.localhost
ServerName localhost.mydomain.com.au # << using this one
apachectl restart
(I normally use mydomain.com.au.localhost so I'm leaving them in for later use.)
I had the same issue using Hybrid Auth 2.8. It relates to our custom session handler which is set by session_set_save_handler().
Hybrid Auth uses standard PHP sessions, so after redirecting and opening a new session, Hybrid Auth starts using standard PHP file sessions instead of your custom session handler. This result in the loss of config data from our session and getting this error message.
I resolved this issue by adding our own custom session handler at the top of hybridauth/index.php (located in the same dir as config.php and live.php).
This forces Hybrid Auth to use your custom session handler.
I found this problem that seems unsolvable. I was giving up, that's when my instinct led me to do a test and voila everything working.
For anyone with the same problem have a question: The file that calls the API is in the same directory it?
Me only worked when I put my file in the same folder as the config.php file. Try it there and tell me if it works!
A hug
and Greetings to all!
I solved my particular HybridAuth "You cannot access this page directly" error with the domain name on the session cookie. My app exists on a subdomain and I'd designed the redirect to point to socialize.sub.domain.tld, and the cookie wasn't reaching the _Endpoint.
Changing the session domain to .domain.tld solved it. - Hope this helps :)
Related
I am new to Codeigniter and I have recently started a project using Codeigniter v3.10 and the Ion-Auth library for user actions.
When I try to access the login page base_url/auth/login I get a 404 error.How can I troublehsoot/solve this? I don't see anything in my network tab in the browser.
I copied and configured the files as presented in user docs.
Thank you in advance
base_url/index.php/auth/login
or use .htaccess to remove index.php
I am using laravel 4.2. After my login code, I redirect to another route for dashboard. But session is not persistent on my dashboard function
This is my code on login function
Session::put('email', $userObject->email);
Session::put('firstName', $userObject->first_name);
Session::put('lastName', $userObject->last_name);
Session::save();
return Redirect::to('/account/dashboard');
if i try to print Session::all() right after Session::save(); I could get the values, But after redirection got nothing. Of course my storage path has the write permissions (0777) Session driver is 'file' Also tried with database, but no luck Any help is highly appreciated, stuck on this for a week almost.
Issue caused because of PHP closing tag on a payment gateway library. It was included in the autoload.
Things to check if session issue comes:
Check for errors using debug true.
Check for exceptions in log file(storage folder)
Do not include PHP closing tag on your files. Before installing a custom library make sure that it doesnot have a closing tag or an error
Do not copy code from websites. if you do so, just paste it to notepad and then copy paste to your editor
I'm doing a laravel app but when I try to create an account it gives a csrf error..
When I check what cookies the website have, I find that I have no cookies, there should be a XSFR-TOKEN and a laravel_session cookies, but laravel is not generating any of those cookies, so it gives me a token not found when i try to create an account.. anyone know why it does that? any idea how to fix that?
Also just installed a new clean laravel and find out if I put the "app" view inside of a folder it also happends and doesnt generate the cookies, I have tried to change the folder permissions but the problem persists.
Open your http app/Http/Kernel.php file and check if your Kernel::$middleware array contains:
Illuminate\Cookie\Middleware\EncryptCookies
Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse
Illuminate\Session\Middleware\StartSession (this is middleware which is responsible for passing data to session driver in Laravel 5)
Illuminate\View\Middleware\ShareErrorsFromSession
App\Http\Middleware\VerifyCsrfToken
To clarify - Kernel::$middleware array contains middleware which is executed on every HTTP request. By default it contains middleware that is essential for session support in Laravel. Perhaphs you accidentaly deleted them.
Here is original file: https://github.com/laravel/laravel/blob/v5.0.22/app/Http/Kernel.php
I have generated the Backend Application for the Symfony(1.4 and ORM Propel) project, in my Production env. But on calling the URL as http://www.mydomain.com/backend.php it is showing 404. Is there any config error or something like that..
Look inside your web folder and make sure that backend.php actually exists there, it might have been named something else [typo maybe]. Does mydomain.com work ?
Update
Disable/rename your .htaccess file temporarily and see if this fixes it. It looks like mod_rewrite is catching "backend.php" and passing it on as a module name.
The Problem was due to the Permission of the file i.e backend.php. I have changed the Owner/Group permission and the backend app started working. If any one had this kind of a problem, please check the file permissions, might help!
For rendering 404 page, the third parameter in your front controller must be false.
Like this:
ProjectConfiguration::getApplicationConfiguration('backend', 'dev', false);
my host account is something like:
~
~/public_html
~/public_html/system/application
to access my web, I need to put http://example.com/~userid in address bar
I install codeigniter in the ~/public_html directory, I can access http://example.com/~userid.
The Welcome page shows correctly, and the related user guide pages show correctly.
The problem is: if I create a new controller, and create new views, the web page just show "Error 404: Document Not Found". If I use http://example.com/~userid/welcome/index it has the same problem.
If I use base_url() function it shows http://example.com/~userid/
What should I do do fix this problem?
Thanks in advance!
Try http://example.com/~userid/index.php/welcome/index.
It looks like your URL rewriting is not set up or badly configured. This is the default way if URL rewriting is disabled.
EDIT See this page of the user guide, especially the section "Removing the index.php file" on how to set up URL rewriting.