Hot answers tagged

8

I am the developer of Akeeba Backup. There are two different CRON scripts supplied with Akeeba Backup Professional. The recommended method is using the native CRON script which bypasses the web server entirely and runs the backup process essentially as a standalone PHP command line application. But that's not the object of your question. The legacy backup ...


7

The global variable $mainframe was remove in Joomla 1.6 and therefore will not work from that version onwards. global $mainframe should be replaced with $mainframe = JFactory::getApplication(); but most people tend to use $app instead. So you code should be like this: $app = JFactory::getApplication(); $app->getSession(); Hope this helps


7

If you look at the session.php file, you see the following: public function isActive() { return (bool) ($this->_state == 'active'); } Which is the function you're calling. I'm not sure if this was done purposely or if it was a mistake, but it will always return 1. Instead, you use: $session = JFactory::getSession(); echo $session->getState(); ...


6

JSession is based on the standard PHP session handling mechanism but I would not say they are interchangeable, as Joomla is directly "talking" to JSession and not to the super global. In backend you select a session handler (the default being the database) where Joomla will store session related informations, basically it's serializing the content of $...


6

Similar to @codinghands's answer, writing the session to the database caused us to have too many connections: https://stackoverflow.com/questions/14506124/joomla-is-causing-too-many-connections-database-errors The database wasn't corrupted, but it brought our site down. We managed to resolve it by changing the session handler to none. In addition, you may ...


6

I believe changes were made to Joomla with the release of version 3.8.4, and that the session table will no longer be cleared if using 'Database' as the session handler. See this page on Github. The recommendation was to change the session handler from 'Database' to 'PHP'. To change this setting, log into the backend of the website. Access the System -> ...


5

It looks like you're creating a new cart array instead of starting with your stored data. Try this: $session = JFactory::getSession(); $cart = $session->get('cart',array('items'=>array())); $cart['items'][] = array( 'action' => $app->input->get('action', 'add', 'STRING'), 'domain_name' => $app->input->get('...


5

I've got a solution after reading the various pull requests on GitHub as pointed out above by Adam Gatt and Drew G. In the summary of changes for github.com/joomla/joomla-cms/pull/19548, is says that database session data is cleared according to the schedule set by PHPs session probabilistic garbage collection. Checking my PHP configuration, I found that ...


4

Edit: It seams that the answer is not correct. The default Joomla Session Handler (Database) does not lock the session while processing. So you don't have to worry about locking. Anyway its possible that you override that session data of the first request with data of the second requests.


4

It's simple, your var $temp is a reference of the session object. So if you change the content of the object you change the session object itself. You have to clone the object: $temp = clone $session->get('whoami'); or you create a new object: $temp = new stdClass(); $temp->type = $session->get('whoami')->type; $temp->id = $session->get(...


4

There's actually a free Joomla! extension that will do just this. It's called Session Keeper and you can view it in the JED here: Session Keeper It worked for my site when I utilized it, so hopefully it works for you as well! It allows you to set session lengths and display modal pop-ups when sessions start to expire. Hope it works for you! Cheers, -J


4

Regarding why your session was not expiring, if you were on a page that had a Joomla login module, the session would never time out. The Joomla login module enables keepalive for all pages where it appears. REFERENCE: http://extensions.joomla.org/extension/session-keeper


3

This is a very common problem in Joomla installs and to be honest there isn't a super simple fix. We've implemented a limited fix in 3.4 which allows you to clear the access rights cached for the currently logged in user (https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/user/user.php#L488). However it will not change the access rights of ...


3

To load the session you need to get it from JFactory. $session = JFactory::getSession(); Read more on How to access session variables set by an external script.


3

It's hard to say exactly what's wrong, but here's a couple of things you can try (please backup your configuration.php and .htaceess files before making any changes). Although you say your username/password is correct, try creating a new super-admin user by following this guide. What version of PHP/mySQL are your new server using? Is it the same as the old ...


3

FoF has a handy _csrfProtection routine in the controller, with several ways to check the token: JUtility::getToken() (for Joomla 2.5, removed from Joomla 3.x) $session->getToken() $session->getFormToken() or, the _token field in any of the previous instances https://github.com/akeeba/fof/blob/development/fof/controller/controller.php#L3308


3

Joomla uses the PHP session functions to create its JSession object, but it provides wrapper functions and namespaces the session to keep the data segregated. If you dump the PHP superglobal $_SESSION you will see the Joomla session items.


3

As for ressources about $mainframe: http://docs.joomla.org/J2.5:What's_new_in_Joomla_2.5 http://docs.joomla.org/Adapting_a_Joomla_1.5_extension_to_Joomla_1.6#Global_Variables_.28.24option_and_.24mainframe.29_are_Gone (Found using Google)


3

Your using the wrong session. If you follow the logic down the class chain for $mainframe->initialize you will find, depending on your version of joomla, a line like https://github.com/joomla/joomla-cms/blob/staging/libraries/joomla/application/web.php#L1062 $session = JSession::getInstance($handler, $options); That session creation call contains the ...


3

Just to add my 2 cents: I've found in earlier versions of Joomla that the _sessions table often becomes corrupted on sites receiving a large number of unique visitors and hence open sessions, bringing the site down until the table is repaired / cleared. Using None resolved this for me.


3

In the none option it use the default php session handle, which use files to store the session data. In the database option it use the database to store the session data. In http://www.tuxradar.com/practicalphp/10/3/7 you can know more about Files vs. Databases in the session


3

Welcome to the world of asynchronous calls. My advice is don't use sessions for the AJAX/RESTful calls at all. The most I would do is have some sort of authentication token so you know who is making the call.


3

You don't have to write your own JSession class, but you'll need to write a class extending JSessionStorage to integrate with Joomla's session handling. Most likely you'll run into trouble when trying to set the the session handler trough the Global Configuration. Either override JFormFieldSessionHandler with a version that includes your handler or just ...


3

You could write a template override for the login template being called when the standard login url is displayed. There you create a HTTP 302 Move response status. Or you write a url rewrite to your .htaccess. Both solutions could get you where you wanna be, but I would consider them 'dirty'.


3

Solution A: Slightly adjusted array structure You have only your itemid and the corresponding quantity in your array. Why don't you use the itemid as array index ($cart['items'][<ITEMID>]) so you could easily update your quantity if the index already exists. $cart['items'][100] = 10 $cart['items'][236] = 5 your itemid --^ ^-- your quantity ...


3

var id='<?php $s = JFactory::getSession(); echo $s->getId();?>'; console.log(id); Simple. That's enough internet for today. For more information on accessing session information please see the Joomla Session API Documentation


3

Plotalot includes various variables that can be used in sql queries, eg. %%J_USER_ID%% is the currently logged in user_id. The Plotalot User Documentation Available as PDF here


3

Found the answer. When I renamed the database I also had to re-assign the database user to this database.


2

Bases on what I've seen, there are a few ways for session data to "go missing". The first way is exactly what people have mentioned or suggested already. This is where you hit the session timer boundary. Once the session timer is reached, the session is cleared from memory. When you log out, your session data is cleared. It depends on which log out ...


2

Joomla allows you to create new Session Storage backends, which may solve your problem. Just extend JSessionStorage with your custom session class, and then you can set the handler in your configuration.php file directly. (Custom session storage backends don't show up in the global admin config.)


Only top voted, non community-wiki answers of a minimum length are eligible