You are here: Re: Where am I wrong?- one possible path :) « All PHP « IT news, forums, messages
Re: Where am I wrong?- one possible path :)

Posted by windandwaves on 01/07/06 09:04

Oujdeivί wrote:
> Here's what I have come up with so far :)
>
> "Cruddiest Adding Machine in Hostory"
>
> ==== total.php====
> <?php
> if(!session_id()) session_start();
> session_register("your_id");//used for older versions of PHP
> $HTTP_SESSION_VARS['your_id']=$your_id;//used for older versions of
> PHP $_SESSION['your_id']=$your_id;
> //tested on PHP4 on Linux, FreeBSD and Windows.
>
> if (!session_is_registered('total')) {
> session_register('total');
> $total = 0;
> }
>
> echo "$total";
>>
>
>
> ==== add.php====
> <?php
> if(!session_id()) session_start();
> session_register("your_id");//used for older versions of PHP
> $HTTP_SESSION_VARS['your_id']=$your_id;//used for older versions of
> PHP $_SESSION['your_id']=$your_id;
> //tested on PHP4 on Linux, FreeBSD and Windows.
>
> function addit($first_number,$second_number){
> $total_sum = $first_number + $second_number;
> return $total_sum;
> }
>
> $sort = $HTTP_GET_VARS["var1"];
> $mode = $HTTP_GET_VARS["var2"];
>
> $total = addit($var1,$var2);
>>
>
> This is just functional enough, as part2 of the code is a pop-up
> window that asks for a selection in a well, list of sorts, and then
> closes, but it needs some method of returning the selection
> information to the part1 window.
>
> Thanks for the help guys, sometimes it's just about asking questions.
>
> p.d.
>
> Balazs Wellisch wrote:
>> "Oujdeivί" <a@b.com> wrote in message
>> news:eSHvf.5096$Hl6.3059@newsread3.news.pas.earthlink.net...
>>> part1 stays active while part2 is called, after part2 finished,
>>> part1 needs to act upon the results, and I need to keep the data
>>> collected in part1 intact.
>>
>> Then maybe you could call part2 internally from within part1 with
>> eval() or system() instead?

This is what I do:


in all files I have as the first line:

require_once("_startup.php");

then in the file _startup.php I have:

$expiry = 60 * 60 * 24 * 1000;
ini_set('session.cache_limiter', 'nocache');
ini_set('session.use_trans_sid', 1);
ini_set('arg_separator.output', "&amp;");
ini_set('session.use_cookies', 1);
ini_set('session.use_only_cookies', 0);
ini_set('session.cookie_lifetime',
$expiry);//session_set_cookie_params($expiry);
session_start();
setcookie("CookieTest", "t");
ob_start("trimmer");

function sid($withamp) {
if($_COOKIE["CookieTest"] == "t") {
return '';
}
setcookie("CookieTest", "t");
$s = session_id();
if($withamp) {
$v = '&amp;';
}
$v .= 'PHPSESSID='.$s;
return $v;
}

Then for any links within my site, I have (e.g.)
echo '<a href="mylink.php?'.sid(false).'">click here</a>';
echo '<a href="mylink.php?a=2'.sid(true).'">or click here</a>';

works a treat - I am able to track my visitors, I dont have the annoying
session IDs in the URLs, except for people without cookies, however, most
importantly, I dont have to add anything to my files except the require_once
line.

Having said that, I am a bit of a cowboy in the PHP arena, so you may want
to wait until someone tells us that is all wrong ;-)

Cheers

Nicolaas

 

Navigation:

[Reply to this message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация