Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

OT: Restrict Access to page

LEGEND ,
Oct 15, 2006 Oct 15, 2006

Copy link to clipboard

Copied

If I'm going to do this manually, is there anything I need to do *other*
than to check on the existence of the session variable?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================



TOPICS
Server side applications

Views

805
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 15, 2006 Oct 15, 2006

Copy link to clipboard

Copied

Murray *ACE* wrote:
> If I'm going to do this manually, is there anything I need to do *other*
> than to check on the existence of the session variable?

No.

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 15, 2006 Oct 15, 2006

Copy link to clipboard

Copied

Thanks, David. Why on earth does the DW SB for that generate so much code?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:egt9c9$nql$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> If I'm going to do this manually, is there anything I need to do *other*
>> than to check on the existence of the session variable?
>
> No.
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 15, 2006 Oct 15, 2006

Copy link to clipboard

Copied

Regarding my previous question - these lines inserted by DW on pages that I
want to restrict access on are causing things to hang -

if (!isset($_SESSION)) {
session_start();
}

Do I need to have that on each such restricted page?

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:egtaun$pje$1@forums.macromedia.com...
> Thanks, David. Why on earth does the DW SB for that generate so much
> code?
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.dreamweavermx-templates.com - Template Triage!
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
> ==================
>
>
> "David Powers" <david@example.com> wrote in message
> news:egt9c9$nql$1@forums.macromedia.com...
>> Murray *ACE* wrote:
>>> If I'm going to do this manually, is there anything I need to do *other*
>>> than to check on the existence of the session variable?
>>
>> No.
>>
>> --
>> David Powers
>> Adobe Community Expert
>> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
>> http://foundationphp.com/
>
>


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 15, 2006 Oct 15, 2006

Copy link to clipboard

Copied

Murray *ACE* wrote:
> Regarding my previous question - these lines inserted by DW on pages that I
> want to restrict access on are causing things to hang -
>
> if (!isset($_SESSION)) {
> session_start();
> }
>
> Do I need to have that on each such restricted page?

Yes, of course, if you want to use a $_SESSION variable, you must
initiate a session.

You don't need the conditional clause. That was added to Dreamweaver 8
at my suggestion because Dreamweaver server behaviors that rely on
sessions all insert session_start(). If you have two on the same page,
it generates a warning message.

For a manual restrict access to page, this is all you need:

<?php
session_start();
if (!isset($_SESSION['name_of_session_variable'])) {
header('Location: http://www.example.com/login.php');
exit;
}
?>

The Dreamweaver restrict access to page SB checks other things such as
access level. It also adds a query string to the redirect URL, so that
the visitor can redirected to the same page after successfully logging
in (as long as that option is selected in the Log In SB).

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 15, 2006 Oct 15, 2006

Copy link to clipboard

Copied

Thanks, David. I'll give that a try. I'm not sure why it's making things
hang, but when going to one of those pages, I get a timeout error....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"David Powers" <david@example.com> wrote in message
news:egtfr1$188$1@forums.macromedia.com...
> Murray *ACE* wrote:
>> Regarding my previous question - these lines inserted by DW on pages that
>> I want to restrict access on are causing things to hang -
>>
>> if (!isset($_SESSION)) {
>> session_start();
>> }
>>
>> Do I need to have that on each such restricted page?
>
> Yes, of course, if you want to use a $_SESSION variable, you must initiate
> a session.
>
> You don't need the conditional clause. That was added to Dreamweaver 8 at
> my suggestion because Dreamweaver server behaviors that rely on sessions
> all insert session_start(). If you have two on the same page, it generates
> a warning message.
>
> For a manual restrict access to page, this is all you need:
>
> <?php
> session_start();
> if (!isset($_SESSION['name_of_session_variable'])) {
> header('Location: http://www.example.com/login.php');
> exit;
> }
> ?>
>
> The Dreamweaver restrict access to page SB checks other things such as
> access level. It also adds a query string to the redirect URL, so that the
> visitor can redirected to the same page after successfully logging in (as
> long as that option is selected in the Log In SB).
>
> --
> David Powers
> Adobe Community Expert
> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
> http://foundationphp.com/


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 15, 2006 Oct 15, 2006

Copy link to clipboard

Copied

On 15 Oct 2006 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:

> Thanks, David. I'll give that a try. I'm not sure why it's making
> things hang, but when going to one of those pages, I get a timeout
> error....

The other option, if this is a set of pages in a single directory on an
Apache server, is to restrict access to the directory using .htaccess and
.htpasswd.

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 15, 2006 Oct 15, 2006

Copy link to clipboard

Copied

Yes, I thought of that, too, but it was so much less of a challenge.... 8)

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Joe Makowiec" <makowiec@invalid.invalid> wrote in message
news:Xns985D6F402E610makowiecatnycapdotrE@216.104.212.96...
> On 15 Oct 2006 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:
>
>> Thanks, David. I'll give that a try. I'm not sure why it's making
>> things hang, but when going to one of those pages, I get a timeout
>> error....
>
> The other option, if this is a set of pages in a single directory on an
> Apache server, is to restrict access to the directory using .htaccess and
> .htpasswd.
>
> --
> Joe Makowiec
> http://makowiec.net/
> Email: http://makowiec.net/email.php


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 15, 2006 Oct 15, 2006

Copy link to clipboard

Copied

This method works fine.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Murray *ACE*" <forums@HAHAgreat-web-sights.com> wrote in message
news:egth4p$2jb$1@forums.macromedia.com...
> Thanks, David. I'll give that a try. I'm not sure why it's making things
> hang, but when going to one of those pages, I get a timeout error....
>
> --
> Murray --- ICQ 71997575
> Adobe Community Expert
> (If you *MUST* email me, don't LAUGH when you do so!)
> ==================
> http://www.dreamweavermx-templates.com - Template Triage!
> http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
> http://www.dwfaq.com - DW FAQs, Tutorials & Resources
> http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
> ==================
>
>
> "David Powers" <david@example.com> wrote in message
> news:egtfr1$188$1@forums.macromedia.com...
>> Murray *ACE* wrote:
>>> Regarding my previous question - these lines inserted by DW on pages
>>> that I want to restrict access on are causing things to hang -
>>>
>>> if (!isset($_SESSION)) {
>>> session_start();
>>> }
>>>
>>> Do I need to have that on each such restricted page?
>>
>> Yes, of course, if you want to use a $_SESSION variable, you must
>> initiate a session.
>>
>> You don't need the conditional clause. That was added to Dreamweaver 8 at
>> my suggestion because Dreamweaver server behaviors that rely on sessions
>> all insert session_start(). If you have two on the same page, it
>> generates a warning message.
>>
>> For a manual restrict access to page, this is all you need:
>>
>> <?php
>> session_start();
>> if (!isset($_SESSION['name_of_session_variable'])) {
>> header('Location: http://www.example.com/login.php');
>> exit;
>> }
>> ?>
>>
>> The Dreamweaver restrict access to page SB checks other things such as
>> access level. It also adds a query string to the redirect URL, so that
>> the visitor can redirected to the same page after successfully logging in
>> (as long as that option is selected in the Log In SB).
>>
>> --
>> David Powers
>> Adobe Community Expert
>> Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
>> http://foundationphp.com/
>
>


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 15, 2006 Oct 15, 2006

Copy link to clipboard

Copied

On Sun, 15 Oct 2006 15:15:59 +0100, David Powers <david@example.com>
wrote:

><?php
>session_start();
>if (!isset($_SESSION['name_of_session_variable'])) {
> header('Location: http://www.example.com/login.php');
> exit;
> }
>?>

How crucial is the exit; line, David? I have to admit I haven't been
using it in my code. And I've been using a relative link too - time
for some search and replaces I think.
--
Steve
steve at flyingtigerwebdesign dot com

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 15, 2006 Oct 15, 2006

Copy link to clipboard

Copied

On 15 Oct 2006 in macromedia.dreamweaver.appdev, Murray *ACE* wrote:

> Yes, I thought of that, too, but it was so much less of a
> challenge.... 8)

The KISS principle today is often used by software developers,
meaning the software should be designed in the simplest way,
avoiding creeping featurism.

http://en.wikipedia.org/wiki/KISS_principle

--
Joe Makowiec
http://makowiec.net/
Email: http://makowiec.net/email.php

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 15, 2006 Oct 15, 2006

Copy link to clipboard

Copied

Essential, dood.

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Steve" <me@here.com> wrote in message
news:utk4j2hip0m2e6tu00d4jcaa97e5a57a7c@4ax.com...
> On Sun, 15 Oct 2006 15:15:59 +0100, David Powers <david@example.com>
> wrote:
>
>><?php
>>session_start();
>>if (!isset($_SESSION['name_of_session_variable'])) {
>> header('Location: http://www.example.com/login.php');
>> exit;
>> }
>>?>
>
> How crucial is the exit; line, David? I have to admit I haven't been
> using it in my code. And I've been using a relative link too - time
> for some search and replaces I think.
> --
> Steve
> steve at flyingtigerwebdesign dot com


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 15, 2006 Oct 15, 2006

Copy link to clipboard

Copied

On Sun, 15 Oct 2006 11:38:44 -0400, "Murray *ACE*"
<forums@HAHAgreat-web-sights.com> wrote:

>Essential, dood.

Yebbut it works fine without exit and with a relative link. Anyway, as
usual a trip to the PHP manual explains all. Such a good resource -
can't wait for someone to transfer it to audio so I can put it onto my
iPod! How about it, DP? :-)
--
Steve
steve at flyingtigerwebdesign dot com

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 15, 2006 Oct 15, 2006

Copy link to clipboard

Copied

Steve wrote:
> Yebbut it works fine without exit and with a relative link.

Without exit, there's a danger that the rest of the script will be
displayed. Using exit guarantees that the script finishes there.

Relative links work fine, but they're frowned upon by the HTTP police.

> the PHP manual explains all. Such a good resource -
> can't wait for someone to transfer it to audio so I can put it onto my
> iPod! How about it, DP? :-)

Oh, yeah. That'd keep me off the streets for a few Sunday afternoons. ;-p

--
David Powers
Adobe Community Expert
Author, "Foundation PHP for Dreamweaver 8" (friends of ED)
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Oct 15, 2006 Oct 15, 2006

Copy link to clipboard

Copied

LATEST
If the redirection is the last thing in the script (which it often is) then
you won't notice the 'essential' character of that exit; function. But -
embed the redirection in the middle of the script and you'll bada bing right
out the window....

--
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.dreamweavermx-templates.com - Template Triage!
http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs, Tutorials & Resources
http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
==================


"Steve" <me@here.com> wrote in message
news:ftl4j2hr0gli7jkcu77h8r6ppbda63cjqm@4ax.com...
> On Sun, 15 Oct 2006 11:38:44 -0400, "Murray *ACE*"
> <forums@HAHAgreat-web-sights.com> wrote:
>
>>Essential, dood.
>
> Yebbut it works fine without exit and with a relative link. Anyway, as
> usual a trip to the PHP manual explains all. Such a good resource -
> can't wait for someone to transfer it to audio so I can put it onto my
> iPod! How about it, DP? :-)
> --
> Steve
> steve at flyingtigerwebdesign dot com


Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines