1
Dave_L
Cookie prefix
  • 2003/12/21 16:33

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


I don't know if this is already on the list, but it would be helpful if there were a configurable cookie name prefix used for all cookies. This would prevent cookie name conflicts if you have more than one XOOPS installation on the same domain, or have other web applications that use the same cookie names.

A related request is to have a common function xoops_setcookie() that's used for setting all cookies, both by the core and by addon modules. That would make it possible to make changes such as adding a cookie prefix, or changing the other cookie attributes (domain, path, expiration time), with a single code change.

2
DonXoop
Re: Cookie prefix

Is the "Name for user cookies" option in Admin/Prefs/General what you're looking for?

3
Dave_L
Re: Cookie prefix
  • 2003/12/21 17:05

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


No, that's only used for a particular cookie. The prefix would be prepended to all cookies.

Right now these cookies are set on my installation:

xoops_user
NewBBLastVisitTemp
newbb_topic_lastread
NewBBLastVisit
votedPolls[1]

I'd like to be able to add a custom prefix to each of the cookie names, e.g.:

Axoops_xoops_user
Axoops_NewBBLastVisitTemp
Axoops_newbb_topic_lastread
Axoops_NewBBLastVisit
Axoops_votedPolls[1]

If I had a second XOOPS installation on the same domain, such as a test platform, I could use a different prefix:

Bxoops_xoops_user
Bxoops_NewBBLastVisitTemp
Bxoops_newbb_topic_lastread
Bxoops_NewBBLastVisit
Bxoops_votedPolls[1]

4
Dave_L
Re: Cookie prefix
  • 2003/12/31 14:04

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


So what do you think? Would the xoops_setcookie() function, and a configurable cookie prefix be a good idea?

Or it might be better to have a cookie class, with methods for setting/getting cookies. The class could also make it easier to store multiple values within single cookies, timestamp the cookies, etc.

5
svaha
Re: Cookie prefix
  • 2003/12/31 17:43

  • svaha

  • Just can't stay away

  • Posts: 896

  • Since: 2003/8/2 2


I think this is a good idea. I noticed the things you describe myself, when I was looking for the cookie of my site. My approach is only a different angle. I want to write an info for users to be and explain why XOOPS uses a cookie and where they can find it on their own computer, so they can check for themselves that there is no personal data in the cookie. But now this is a little difficult.

Aloha

6
Brad
Re: Cookie prefix
  • 2004/4/27 14:08

  • Brad

  • Not too shy to talk

  • Posts: 150

  • Since: 2003/12/4


Dave -

Did anything further ever come of this? For what it's worth, I think it's a swell idea (and I don't use "swell" often).

If you haven't yet, perhaps you should submit it to the Feature Requests. Hopefully it can make it into the next release of Xoops.

7
Mithrandir
Re: Cookie prefix

I guess a little function to automatically add a prefix before setting a cookie should be no problem - but do keep in mind that it is also very much a module developer issue, there can be as many helpful functions in the core, but they need to be used in the modules.

Does it have to be an individually set prefix? I'm thinking that it could just take the same prefix as the DB tables? Otherwise, putting this in the general settings in XOOPS preferences should be no problem since there are already some cookie settings there (almost enough for an individual setting category )

8
phppp
Re: Cookie prefix
  • 2004/4/27 15:25

  • phppp

  • XOOPS Contributor

  • Posts: 2857

  • Since: 2004/1/25


I am using a function exactly the same name xoops_setcookie()


$cookie_list = array(
    array(
"path"=>"/xoops""domain"=>".domain.com"),
    array(
"path"=>"/""domain"=>"xoops.domain.com"),
    array(
"path"=>"/","domain"=>".anotherdomain.com...")// this does not work yet
);

function 
xoops_setcookie()
{
  
$vars=array('name','value','expire''path','domain','secure'); 

  for (
$i=0;$i<func_num_args();$i++) { 
     ${
$vars[$i]}=func_get_arg($i); 
  } 

  if (!
$name) { return false; } 

  if (!isset(
$expire) || ($expire 0)) $expire time();
  
      global 
$cookie_list;
    if(!
is_array($cookie_list)) {
        
$path = isset($path)?$path:"/";
        
send_htCookie($name$value$expire$path$domain$secure);
    } else {        
        foreach(
$cookie_list as $cookie){
            
$_path = isset($path)?$path:$cookie["path"];
            
$_domain = isset($domain)?$domain:$cookie["domain"];
            
$rest false;
            
$rest send_htCookie($name$value$expire$_path$_domain$secure);
        }
    }
}

function 
send_htCookie() { 
  
$vars=array('varname','varval','expire''path','domain','secure'); 

  for (
$i=0;$i<func_num_args();$i++) { 
     ${
$vars[$i]}=func_get_arg($i); 
  } 

  if (!
$varname) { return false; } 

  
$COOKIE "Set-Cookie: $varname=$varval"
  if (isset(
$expire) && ($expire 0)) { 
     
$COOKIE .= "; EXPIRES="
     
gmdate("D, d M Y H:i:s",$expire) . 
     
" GMT";} 
  if (isset(
$domain)) { $COOKIE .= "; DOMAIN=$domain"; } 
  if (isset(
$path))  { $COOKIE .= "; PATH=$path"; } 
  if (isset(
$secure) && $secure>0) { $COOKIE .= "; SECURE"; } 

  
header($COOKIE,false); 
  return 
true
}

9
Brad
Re: Cookie prefix
  • 2004/4/27 17:06

  • Brad

  • Not too shy to talk

  • Posts: 150

  • Since: 2003/12/4


Quote:
Mithrandir wrote:
Does it have to be an individually set prefix? I'm thinking that it could just take the same prefix as the DB tables? Otherwise, putting this in the general settings in XOOPS preferences should be no problem since there are already some cookie settings there (almost enough for an individual setting category )

I would think both. Have it default to the DB table prefix but let the user override it via the general settings.

10
Dave_L
Re: Cookie prefix
  • 2004/4/27 17:19

  • Dave_L

  • XOOPS is my life!

  • Posts: 2277

  • Since: 2003/11/7


Yes, I also think the cookie prefix should be independent of the database table prefix.

Login

Who's Online

427 user(s) are online (313 user(s) are browsing Support Forums)


Members: 1


Guests: 426


Runeher2,

more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits