Jump to content

Creating a session and sending it thru


jw18

Recommended Posts

Hi there,

 

First I will say my experience in PHP is rather limited. Before posting on here I have searched a lot on Google to try and find the code. Nothing I have used seems to work... but I know what I want to do is simple.

 

Basically I have two pages on my website: Page1.php and Page 2.php

 

I do not want someone to be able to view Page2.php until they have viewed Page1.php. So I think I need to start a session on Page 1 which is checked on Page 2. This is the code I'm looking to find. If someone could help out or point me to something that would assist me, I'd greatly appreciate.

 

This is what I was working with:

 

Page 1:

<?php
session_start();
$_SESSION['name']="test";
?>

<a href="page2.php"> click here </a>

 

Page 2:

<?php
if ( !isset( $_SESSION['test'])) {
Header("Location: page1.php");
}
?>

Test Content 

 

Thank so much for any help at all!

 

Link to comment
Share on other sites

Ok. I tried adding that to page2 (page 1 already had it)

 

So now it's:

 

"<?php

session_start()

if ( !isset( $_SESSION['test'])) {

Header("Location: page1.php");

}

?>"

 

But it still just sends it back to page1.php when I start from that page. So it's like on page1 it's not creating a session or it's not passing it thru.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.