Re: Re: setting a session with a text link?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



<a href="<?php echo $_SERVER['PHP_SELF']?>?_SESSION[switch]=0">off</a>

This *might* work, if you have session.auto_start set to ON, so that
the session is started before PHP processes the URL, and if you have
register_globals set to "ON"

But I doubt it, as that would be horrible security, because you really
do not want to allow users to pollute your $_SESSION data.

Plus, of course, if you're trying to get sessions turned on/off from
this, you'll have the session auto_start and then turn it off and
destroy it within the script if they ask for it to be off, rather than
have it actually not be turned on in the first place.

Work through what happens with your link and the session
construction/tear-down in slow-motion to see why you can't really do
this the simplistic way you are trying.

On Mon, August 21, 2006 11:01 am, Ross wrote:
> That is it but can I not set the session variable directly from the
> link?
> Something like..
>
> print('<A href="' . $_SERVER['PHP_SELF'] .
> '?$_SESSION['switch=on']">Switch
> on</A><BR>
>
> ""Ivo F.A.C. Fokkema"" <I.F.A.C.Fokkema@xxxxxxx> wrote in message
> news:pan.2006.08.21.15.12.55.310164@xxxxxxxxxx
>> On Mon, 21 Aug 2006 13:08:04 +0100, Ross wrote:
>>
>>> I want to set a session with a text link, am having problems with
>>> the
>>> syntax. The link swiches the session to on or off.
>>>
>>>
>>> <a href="" class="link_text">swtich off</a>
>>> href="" class="link_text">swtich on</a>
>>>
>>> I want to do this but the syntax is incorrect.
>>>
>>> <?=$_SERVER['PHP_SELF']?$_SESSION['switch]='0'; ?>
>>> <?=$_SERVER['PHP_SELF']?$_SESSION['switch]='1'; ?>
>>>
>>> what is the correct syntax for this line?
>>
>> I am not too sure on what you're trying to do... but maybe this
>> helps?
>> // Untested code!
>>
>> <?php
>> print('<A href="' . $_SERVER['PHP_SELF'] . '?switch=on">Switch
>> on</A><BR>
>>      '<A href="' . $_SERVER['PHP_SELF'] . '?switch=off">Switch
>> off</A><BR>');
>>
>> if (isset($_GET['switch'])) {
>>    // Set switch, as requested.
>>    $_SESSION['switch'] = ($_GET['switch'] == 'on'? 1 : 0);
>> }
>> ?>
>>
>> Hope this helps anything...
>>
>> Ivo
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
Like Music?
http://l-i-e.com/artists.htm

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux