I have an issue when using the HybridAuth plugin. I have included the plugin as a popup in in my home page. When clicking on the login button from home page the plugin will load in colorbox.
In my server I can't use default php session save path so that I have set it as php temp path for saving session like below in index.php of my root folder.
$dir = sys_get_temp_dir();
session_save_path($dir);
After updating this code, the plugin is authenticating the social media that customer selecting successfully and return back to my site, but it is not passing the below condition,
$hybridauth->isConnectedWith( $_GET["connected_with"] ) // it is always return false
In second case I have updated the session save path in index.php of plugin folder also, but at at that time in the login popup instead of showing login UI it is directly showing an error page like below
"You cannot access this page directly."
Any help would be appreciated. Thanks in advance.
The problem is your default session path:
$dir = sys_get_temp_dir();
session_save_path($dir);
I would print_r sessions to see what got registered. Why do you have issues with default session path? I wouldn't try to alter it and make sure that works first. This is altering the main functionality of HybridAuth.
Why can't you use the default php session save path? are you on a shared host?
--
If you have shell access make sure the web server user has write access to the directory; that should take care of the issue.
As often : RTM and discover the use of isConnectedWith
isConnectedWith()
Return a true or false if the current user is connected to a given
provider. Hybrid_Auth::isConnectedWith() use PHP Sessions. To know
more refer to the HybridAuth Sessions section.
Hybrid_Auth::isConnectedWith(provider)
Where provider is the name of the tested service. eg : Hybrid_Auth::isConnectedWith('Twitter')
Be sure that your $_GET returns the good service name.
If you want a list of connected providers : Hybrid_Auth::getConnectedProviders()
If you want to inspect session's datas : Hybrid_Auth::getSessionData()
API !
Add your 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.
Related
I am using sessions to check if the user is logged in. In my project, there are some pages, where session check is not required i.e user can access it without logging in. How I disable session check on selective pages? Instead of writing say session_check on every page that needs session, i want to know if there is a way to implement no_session_check() on selected pages. As the number of pages that require session check are more than pages that do not work. I am using codeigniter. Thanks
First you created the session checking function in library file .. if u want session on that controller just call that library function..
Refer this link:
I have a problem with session. I have website for example www.mysite.com and also there are some sub-domain sub1.mysite.com sub2.mysite.com, I want to log in only once and I want to use the same session data for booth domains.
First it would be great if I log in on the main domain it would work in the sub-domains. I have been read a several forums, and now I'm totally confused. Most of these forums told I have to take this code to my main domain login php file:
ini_set('session.cookie_domain','.mysite.com');
session_start();
So I puted this code to my main login php and I putted just this to the sub-domains:
session_start();
It doesn't work, please somebody explain me what should I do, what is the possible problem? Also this should handle automatically to save session data's to coockies? I mean if I create for example this session variable
$_SESSION['email'] = $user_datas['email'];
it should available in the sub-domain as well if it working correctly?
My second question if I log in on sub-domain(for example sub1.mysite.com) will it work to use this session on the other sub-domain and the main domain?(sub2.mysite.com and www.mysite.com)
Thanks,
Zsolt
P.S.: I also checked my php.ini settings on my web hosting provider there is the following line:
session.cookie_domain no value(local value) no value(master value)
I don't know is it good or not...
I have a folder outside /application folder of CodeIgniter called myfolder.
My CI application uses Native PHP sessions and it all works fine. CI version is the latest 3.0-development.
I need to access some of the session data in myfolder/myfile.php. If I do a session_start() and then print_r($_SESSION); then I don't see the session set by CI's session driver. I understand why it doesn't show it.
Do you know any method/hack by which I can refer to session data from the CI's session in myfolder. for example by directly including, say, Codeigniter/libraries/session/drivers/session_native.php or any other file?? I just an array from the session data.
Its a trick but do work. Place this little naughty code just before login redirect. And now you can use ci_session with php native session too ,have fun !
<?php
session_start();
echo $_SESSION['ci_session'] = $this->session->userdata['ci_session'];
?>
The current Session_native.php doesn't seem to change any of the built in session library's preference or interfere with how the session data is saved, i think the following should work:
Get a hold of the session id for the session you want to load
call session_id($sessid) with this session id before session_start()
call session_start()
This should work as long as the various ini settings that control the session lib like session.save_path is the same and maybe (if your host have this extension installed) suhoshin settings like suhosin.session.cryptdocroot doesn't interfere.
You can get in cookeis
<?php
print_r($_COOKIE['ci_session']);
Save the session data which you wants to refer from outside the folder into cookies, which may helps you.
So use cookies to refer data from outside the folder and make sure when you set cookies it should be in proper accessible path
I am using Elgg Application, Inside FB connect plugin i am starting Session and setting some variables in the same folder i am accessing this session attributes its working fine..
But i included one more php file, after log-in if i directly call this page through url session_status is 1 but in other two folders its is set...
How to set session here also, their should be any link between pages to session variables
can any one help...
Fb_connect folder
str= "var/www/elgg/mod/fb_connect
import-contact-plugin-str="var/www/elgg/mod/importer.
new php file i added
url=var/www/elgg/engine/sample.php
When you work with Elgg, you shouldn't change its core. Almost everything can be done by plugins, and that's the preferred way of working with Elgg.
Elgg sessions are kept in database and session start is called on system boot event. When you're in plugin context however, the session is already in place, no need to to additional session_start call.
So if you decide to go on modifying the core, you should run your logic from callback registered to boot system:
elgg_register_event_handler('boot', 'system', YOUR_CALLBACK);
is it possible to remove files from the folder when session will destroy. am doing that when a user come into the site and he can upload files(images, or textfiles), etc.. with out login into the site. and the files 'll store into my project's folder. now i need to do if the user quits from browser with out login i need to delete all the files what he upload in to project folder. how to do this ?
Thanks in advance.
You can do this by implementing your own session handler. This way, you can define a callback for various events, including the destruction of a session. See this link for more information:
http://www.php.net/manual/en/function.session-set-save-handler.php
Update: The problem with that solution is that you need to implement the rest of the session handling code as well (initialize the session, close the session, read from storage, write, garbage collect). However, the linked page above gives a full example that you can add your functionality to.
It all depends on the business decision.
You can do, Do not save the file in projects folder instead save it somewhere else like 'tmp' folder and save the reference of that file (file path) in session.
by unlink("path") function you can do it in PHP .. but it also depends on the logic that you have used.
if you just want to delete uploaded file then unlink is your solution
use session set save handler to create an event handler for session events.
Sriram,
In PHP, seems the server does not keep track of session on its side. Only time the server knows of a session is expired is when it receives the info about the session cookie in the request. If the cookie is there session exist or else, its expired..