![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Aug 2005
Location: Leeds - UK
Posts: 69
Rep Power: 4
![]() |
trouble with sessions
Hi there. I am stuck on sessions again!.
I am creating a session <?php // start the session session_start(); header("Cache-control: private"); //IE 6 Fix error_reporting(E_ALL); Then a session variable $_SESSION['access'] = $access; This is created in the directory www.website.com/home.php I then want to access this variable on a page www.website.com/helpdesk/home.php as below <?php // start the session session_start(); header("Cache-control: private"); //IE 6 Fix error_reporting(E_ALL); if(isset($_SESSION['access']) == false) { $URL="http://www.google.co.uk"; header ("Location: $URL"); } But it dosn't pick up the variable. The above if statement always returns false. Any help?? Thanks in advance |
|
|
|
|
|
#2 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Read the forum's FAQ/rules and learn how to use code tags.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Aug 2005
Location: Leeds - UK
Posts: 69
Rep Power: 4
![]() |
sorry about the code tags. Will do for next time.
Any help with the question?? |
|
|
|
|
|
#4 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Well, your links are no good for assessing your PHP code. They just lead to pages. If you want your session variables to persist, you have to have session continuity either via cookies or as part of the url. If cookies are disabled, there goes that one. Whether or not you have to overtly put the SID in the url depends upon a couple settings. Have you inquired of the PHP manual? Checked those settings? Read up on sessions?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#5 |
|
Programmer
Join Date: Aug 2005
Location: Leeds - UK
Posts: 69
Rep Power: 4
![]() |
I have had a look into sessions. I havn't come acroos continuity. I understood if session start() was used the the session continued.
no? |
|
|
|
|
|
#6 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Suppose your server receives a request from some client. How does your server know that it's a continuing session from a previous request by that client? Http is stateless. It's the provision of a valid session ID by the client that signals continuity. The client provides that via cookie, or via the URL. Again, all this is covered in the PHP manual, which is excellent documentation. If the stateless nature of the client/server paradigm is news to you, you need to brush up on that, also.
If you don't have a lot of session variables, you can keep state information yourself, in much the same way that PHP does. It's really just a convention that someone else has taken the trouble to write for you.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|