Forum Moderators: phranque

Message Too Old, No Replies

.htaccess conditionals?

How do I auto_prepend_file based on cookie presence

         

Simsi

10:59 pm on Nov 4, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi

I'm hoping someone can help here as I've searched high and low any my limited Apache knowledge is letting me down.

I want to use the following statement in .htaccess to prepend (include) a file on a set of documents, but only when cookie "xx" is present:

php_value auto_prepend_file /home/functions.php

The problem I'm having is using .htaccess to determine if the Cookie "xx" is present as I don't want to prepend that file if it isn't.

Any ideas?

Cheers

Simsi

[edited by: Simsi at 11:00 pm (utc) on Nov. 4, 2006]

coopster

1:34 am on Nov 7, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I think you may have to reverse your logic. Instead of checking for the cookie and then including the file, perhaps you will auto prepend the file and inside the script check for the existence of the cookie. If present, continue with the script logic.

Simsi

11:45 am on Nov 7, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Coopster. The problem here is that I don't want to include the script at all if the Cookie doesn't exist. I could do this with a straight include obviously, except I don't want to have code inserted onto every page of the site directly if I can avoid it. I was hoping there might be some sort of "if...else" function in .htaccess or some way of simulating this.

Anyone else have any ideas?