Jump to content

Sessions.


ReVeR

Recommended Posts

Hello.
I have a login scipr tnad i use sessions to store some data. Basicly i have 2 files.
first file index.php has all the login stuff like forms etc, and the other files generates a random number to check for validity.
A/w i need to store the random number after it was generated half way down the page in a session, so then when user presse login butotn, and the script at the top of the page runs, the number is still stored in the session.
I use start_session() in both of my files, index.php and the file that generates the random number, but when i try to do this:
[code]
$_SESSION['image_random_value']
[/code]
in the index.php (the above value is created in the other file.) i get that image_random_value is undefined even though it is defined in the other file.
Any ideas?
Link to comment
Share on other sites

post the other session that is set ok.

Must not be set correctly try one hope one works good luck.

Also make sure you got no white spaces or any html before the session_start();

Is it set like this.
$image_random_value=('$_SESSION['image_random_value']');

or


$image_random_value=('.$_SESSION['image_random_value'].');


or


$image_random_value=('".$_SESSION['image_random_value']."');

its all guess work sorry.

also post the error good luck.
Link to comment
Share on other sites

hmm...well i still got the problem:
file 1: index.php
this file includes anohter file that sets teh session variable to some values, here is my call to get that variable:
[code]
<?php session_start();
include 'news/news.php';
$news=new cnews;
header("Cache-control: private");
$errorMessage = '';
$_SESSION['user']="Unknown";
if (isset($_POST['txtUserId']) && isset($_POST['txtPassword'])) {
    $number   = $_POST['txtNumber'];
    $image_random_value=$_SESSION['image_random_value'];
[/code]
I get the following error:
[code]
Notice: Undefined index: image_random_value in index.php ....
[/code]
THis the the file that sets the session variable:
[code]
<?php
$rand = rand(10000, 99999);
$_SESSION['image_random_value'] = md5($rand);
$image = imagecreate(60, 30);
[/code]

Note do i need to start the session in the other file also or no?
also the second file that makes the image is called half way down the page, and then when the form is submitted the variable is procced in the code above...any ideas where i went wrong?
thx
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.