We study finite time blow-up and global existence of solutions to the Cauchy problem for the porous medium equation with a variable density ρ(x) and a power-like reaction term. We firstly consider the case that ρ(x) decays at infinity like the critical case |x|-2 divided by a positive power of the logarithm of |x| and we show that for small enough initial data, solutions globally exist for any p > 1. On the other hand, when ρ(x) decays at infinity like the critical case |x|-2 multiplied by a positive power of the logarithm of |x|, if the initial datum is small enough, then one has global existence of the solution for any p > m, while if the initial datum is large enough, then the blow-up of the solutions occurs for any p > m. Such results generalize those established in [27] and [28], where it is supposed that ρ(x) decays at infinity like a power of |x|, without logarithmic terms.