Wordpress WP Session Manager variables not always being set - php

I have an issue with the above plugin (WP Session Manager) where the session variables I set, are not always set. I know the PHP I'm using to set the variables is correct as they do work sometimes. But for example, I can have them working perfectly fine and echo'ed out to the screen as a test, then I 'logout' and blank all the variables by setting them to "", then log back in (and set them again) but they do not get echo'ed out this time, meaning they must not be set.
I know one works for definite, as it is used to see if the user is logged in or not, and I only get asked to log in on my site once, I can navigate around pages etc, close the browser and I'm only asked to log back in when I use my logout button to blank the variables.
Does anyone know what might be causing this please? Or is it going to be something very hard to diagnose?
Don't know if it will help or not (to fix the issue), with regards to editing the session timeout time, I see that there is the info on the FAQ page of the plugin, saying that it can be edited using this filter
add_filter( 'wp_session_expiration', function() { return 60 * 60; } ); // Set expiration to 1 hour
But where is this filter found/edited or added?
Hope someone can help with the problem :)
Thanks!

I have fixed this now. Redirecting to a different page instantly was causing an issue, waiting for 1 second before doing the redirect allowed the variables to be set.

Related

Session lost in sub domain url in apache server

I have a session lost problem in sub domain url (test.example.com) after login. But the same code working fine in (i.e example.com). I tried session.cookie_domain but same error exist. Please anybody help in this regards
I had the same experience like you hundreds of times which I finally found the problem. You don't need to worry if cookies enable or disable. You just have to re-declare parts of your scripts (variables-the data which you want to display) in a if else condition. Just redeclare the same thing using !isset and then else with the same variables mentioned twice in the if else condition, if you understand what i mean.e.g if (!isset etc){A+B} else {A+B}. It will call back the same variables over and over. And make sure start session is above the page and define a session e.g session['id'] on that page which you claim missing.. no need to worry about headers or white lines, it has actually nothing to do with it. I've tried it a million times. You don't need to bother using ajax etc. PHP can do almost everything. cheerio.

Problems logging into Magento Admin

Occasionally I run into a problem logging into the Magento admin panel. The username and password I enter is correct and the url in the browser window tells me that I have logged in correctly (ie: I see domain.com/index.php/admin/areallylongstring), however the login window is displayed again. No error message telling me that the log in details are incorrect is displayed, I am just routed back to the log in window. Has anyone come across this before and can anyone please suggest a solution?
Thanks!
Try start a private browser session and see if you can login, if so clear your cookies for the website and you should be able to login.
I occasionally get this problem, next time I get it I will dig into the code with my debugger to see what is actually going on.
This problem arises due to multiple reasons and the cheapest solution for this will be comment out the following lines in one of core files of magento.
FILE :- app/code/core/Mage/Core/Model/Session/Abstract/Varien.php.
// set session cookie params
session_set_cookie_params(
$this->getCookie()->getLifetime(),
$this->getCookie()->getPath()//,
//dependes which versin of mage you are using, you may comment these as well
//$this->getCookie()->getDomain(),
//$this->getCookie()->isSecure(),
//$this->getCookie()->getHttponly()
);
Find out above code in that file and then comment out those three cookies as shown above.
But as I said it is the cheapest and easiest solution that you can go with. For more information, checkout this link

Laravel sessions regenerating on every load

I'm having a lot of problems and I really can't seem to find a solution.
Yesterday, I finished up doing some work on a vagrant box in Laravel. When I shut down the computer, login functionality was working fine.
On opening everything up today I find sessions are no longer working.
I've tried everything I can think of but I cannot log in now and flash data doesn't work.
Every page load a new session is created - e.g using the native driver, if I login, it creates two sessions - one for the login page, and one for the posted login page.
If I use a database driver I get the same result. Every time I click login, I get a further two rows of session data
I can't tell what's happening with the cookie driver but I've tried it and it's not working.
I've tried in Chrome and IE and neither will login. I've tried deleting the contents of the storage folder multiple times, and emptying cookies on the browser side. I did think it may be to do with the time being different on the vm and the local machine but they're synchronised.
Any ideas what could be causing this? Anyone come across this issue before?
edit: I've also now recreated the virtual machine and the problem still exists
second edit: I've now started from scratch using a digitalocean VPS with the same results.
I've stripped out everything in my routes file and all it now has is the following
<?php
Route::get('/sess/set/{value}', function($value) {
Session::set('testv', $value);
Return 'Set ' . $value . ' - ' . Session::get('testv');
});
Route::get('/sess/get', function() {
Return 'Get ' . Session::get('testv');
});
I visit the first page and it shows whatever value I put into the session. Hit the second page and you only get the 'Get ' part without any session value.
session_attributes always has a _token field, I've tried changing the name of the session and the domain and still can't get sessions to work.
edit3: for anyone who comes across this, I never identified the issue. I started a completely new project, copied my controllers and views across, recreated my routes file and everything is now working - although I'm half expecting to be updating this post tomorrow to say it's broken again!
My problem was that I had echo statements in my function. It was keeping the session from being properly created/stored.
I had an echo before my 'return Redirect' so the redirect didn't get the session...
public function login()
{
// auth
if (Auth::attempt(Input::only('email', 'password'), true))
{
return Redirect::route('companies.index');
}
// failed -> back to login
return Redirect::back()->withErrors(['email' => 'Login failed.'])->withInput();
}
Details: http://brainwashinc.com/2014/02/17/laravel-sessions-not-working-in-4-1/
I had this exact problem and with almost identical environments as well. As you experienced as well what ended up working for me was starting a totally fresh Laravel 4.1 project and then copying everything over. However I did also find that by changing one config variable I was able to fix the problem:
In /app/config/session.php change the lifetime config item to something higher than 0. This fixed the issue for me.
I had this same issue and already changed my session values to the 4,1 version. I logged into our server and ran the composer update command, after it finished everything worked fine.
composer update
I spent a whole day with the same issue (session regenerated with almost every request), and could not find anything helpful online. Posting this here in case somebody has the same issue.
Basically the problem was that the session cookie was not set correctly due to template errors. So if you run into this, first check that the session cookie is set with every request via http headers.
In my case I wrongly used something like this in some of my templates:
#section('test')
<p>Some content here</p>
#endsection
This is wrong!
In Laravel 4 it needs to be #stop instead of #endsection:
#section('test')
<p>Some content here</p>
#stop
Using #endsection made the app not finish correctly, so no session cookie was set. There is no trace of anything being wrong in the logfiles however. BTW, this kind of error also leads to after-filters not being applied.
I also has this problem, and it turned out to be with outputting data early - I was already echoing some debug text in the controller action, and then tried setting a session variable for the first time - the session just wouldn't persist, and kept recreating each time - once I removed the output, it worked fine (and fine from then onwards)
I upgraded from Laravel 5.1 to 5.2 and had the issue of numerous sessions being created on every page load. It didn't matter which session driver I used, nor did changing anything in config make it work. (I tried every suggestion on every StackOverflow result produced by Google.)
The solution for me: remove "web" middleware from your routes. Apparently, web middleware is included automatically in 5.2+, so if your routes ALSO specify it, you wind up with multiple sessions being generated.
There are many reasons this can happen, I just ran into this problem myself. The fix for me was to change:
public function getAuthIdentifier()
{
return $this->username;
}
to
public function getAuthIdentifier()
{
return $this->getKey();
}
on the User model.
I've experienced issues related to this. The session file wasn't created every time but sometimes I just can't get the session variable displayed. After hours of experiments I found that the problem was related to Debugbar.
If you're using Debugbar and having session issues, disable it and try again to confirm. There's an issue reported here.

How can I refresh a page/frame when a server not found error page is displayed?

I've searched but haven't been able to find any discussion on this topic:
I have a private webpage (implemented in php) that scrolls through a few different php pages displaying info then refreshing to the next one every minute for use in a fire station displaying latest jobs, weather etc. I currently use header( 'refresh: 60; url=screen2.php' ); in each php file simply pointing to the next file..
The problem is that every once in a while the page fails to load for one reason or another, at which point the "Server not found" page is displayed. When that happens of course the refresh instruction is lost and error page stays there until someone notices the problem and manually refreshes the page. Not ideal..
I should mention the page is displayed on multiple monitors around the fire station and the pc running it is locked away. Hence the hassle of manually refreshing it every so often!
It's important if possible to automatically recover from this situation without human intervention. Is there any way, using frames, php, javascript or otherwise, to refresh again if the error page is shown?
Any ideas would be greatly appreciated.
Thanks!
Adam
You could just use javascript window.location inside a setTimeout function or a meta refresh tag.
There's no reason to need to do it on the PHP side unless you care whether the user can change the refresh information.
You say it "fails to load for one reason or another" - do you know why this is? If the problem is at your server end, then you could set up your server so that its 404 response (or 500 internal server error response, or whatever error it is) contains the header to redirect to the start PHP page.
If the issue is DNS or connection related - ie. the server isn't even contacted and so the "not found" error page is being displayed by the browser, then what you could do is alter this page. This is not easy to do, but in Firefox you can e.g. follow the instructions on http://forums.mozillazine.org/viewtopic.php?f=7&t=492177&start=0 in order to customise the error page shown.
Other than that, it might be better to fix the problem with the page failing to load, that might be simpler :)
You could also save the information in a session.
http://php.net/manual/en/features.sessions.php
Another way that is server-independent is the Web Storage API of javascript. Most modern browsers already support it.

Very odd login behavior... PHP5, Session may be the culprit?

If you go to my main site: www.site.com, and then click "login" - you are taken to the login page: site.com/users/login.php.
At this point, the first time you try to login, and click submit, the page basically just reloads.. no error message (or successful login) is completed.
The 2nd (and 3rd, 4th, etc...) time, everything works like normal. Additionally, for what seems to be the life of the session cookie (15 minutes), it still works normally. If I close the browser, wait 15 minutes, and come back and do this process again, I'm back to the 1st time reload issue...
If I go directly to site.com/users/login.php, without coming from the main page link first, it works properly the first time...
I assume this is something to do with sessions? Have you ever seen/heard of behavior like this? I have no session active on the main page, only the /login.php page starts a session for the first time.
I know this probably isn't enough info to properly debug, but I thought I could at least throw it out there for people who have experienced something similar before....
Months later, the problem was solved. Please see response here for the fix...
session.cookie_domain in php.ini - issues with POSTing forms

Categories