I'd like to at least investigate the possibility of using Drupal's existing system for handling sessions instead of using a separate cookie to determine the number of times a person has visited the site initially.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

guardian’s picture

subscribing

sillygwailo’s picture

FileSize
902 bytes

I don't think using sessions is going to work: if a visitor sees the block for the specified times, then logs in, that user again will see the block, as the session is different. I could put a check for user being logged in so that it doesn't display (if a person has signed up, they've already crossed enough of a hurdle that they're sticking around). As soon as the user logs out, the session is deleted, then the block shows up for the specified amount of times again. I've attached a patch to this for others to test.

Maybe there are other ways to do this that use the Drupal system instead of adding a cookie?

guardian’s picture

not to mention modules like http://drupal.org/project/session_expire

sillygwailo’s picture

Version: 5.x-1.x-dev » 5.x-2.x-dev

http://drupal.org/project/session_api might be able to do this. Moving this to the 2.x branch.

sillygwailo’s picture

Version: 5.x-2.x-dev » 6.x-1.x-dev
FileSize
2.47 KB

An attempt at using Session API module patch attached. In testing, it added another "session" after logging out, starting the count over again. Requires the following table:

CREATE TABLE `wwsgd_visits` (
 `sid` int(11) NOT NULL,
 `visits` int(11) NOT NULL,
 PRIMARY KEY (`sid`)
);
Anonymous’s picture

Assigned: sillygwailo »
Status: Active » Fixed

New maintainer here. I took a different approach with this in the 6.x-2.0 branch. It stores the variables in the Drupal sessions table so that if you have an expiry set on your session the data goes away with the dead sessions. This should prevent databases from getting filled with unnecessary sessions from robots.

It has the added plus of not needing a custom database table.

To use the session table rather than the custom cookie, choose the option in the block configuration page.

As mentioned in the release notes for 6.x-2.0, if you do not get Drupal's session cookie you must find some other way to manage your sessions otherwise all anon visitors get their own unique session id with each page reload. There is plenty of documentation around to help you deal with that issue...

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.