Forum Moderators: coopster

Message Too Old, No Replies

application vars with php

easy with cf, also with php?

         

the_nerd

11:48 am on Nov 9, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I didn't find a solution, so I thought, let's ask the experts ....

I'd like to create a couple of objects (language stuff, for example) - that should be valid for all sessions - so I don't have to waste space and power to create those objects for every new session.

Does anybody know how to make variables available to all sessions?

Thanks a lot,

nerd.

jatar_k

4:11 pm on Nov 9, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



load them into memory

you could do this with apache start up scripts, we had some scripts that did this but I don't believe I have copies and it's been a while.

the_nerd

3:50 pm on Nov 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



thanks, jater_k,

but that sounds rather static. I'd like to be able read and write (and lock) those "application vars" during runtime. Sounds like this concept has no equivalent in php?

nerd

Nutter

3:56 pm on Nov 10, 2005 (gmt 0)

10+ Year Member



What about storing them in a temp file and then updating that file as they change?

jatar_k

4:55 pm on Nov 10, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



just use an included file then as Nutter said

the_nerd

7:42 pm on Nov 14, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



just use an included file then as Nutter said

but then I could read them as well directly from the database.

The idea was to have some kind of cached queries in memory. (For example 10000 strings from a language table that then can be accessed in array form)

Nutter

9:41 pm on Nov 14, 2005 (gmt 0)

10+ Year Member



Wouldn't this work?

$myvariable['login']="Please enter your login";
$myvariable['logout']="Later";
$myvariable['welcome']="Welcome to my super site";
....and so on....

the_nerd

7:02 am on Nov 16, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi nutter,

this would work, of course.

But If I had

langtext [1] = "hi";
langtext [2] = "friend";
...
langtext [100000] = "the end";

wouldn't it be way too "expensive" to initialize and keep this array for every session or even every request if there's no session started?