Jump to content

Recommended Posts

Hey,

I was writing my login.php script, and instead of creating every session one-by-one, I tried to create a function that assigns all the sessions...but it doesn't work for some reason. I don't understand what the mistake is. The code is really simple...

 

function gen_sessions($arr)

{

    foreach ($arr as $k => $v)

    {

            $_SESSION['$k'] = "$v";

    }

}

 

This function is later called in the login.php script itself, after all the validation is done using....

 

$row = mysql_fetch_array ($sql, MYSQL_NUM);

gen_sessions($row);

 

There are no errors, and the login process is also done, but I am not able to access the sessions(session_start() has been added).

 

For example, later in a different page my program is not going through the if conditional:  if((isset($_SESSION['11'])))

 

I have a feeling that it is just some syntax error. Please help...

 

$_SESSION[$k]=$v;

 

Hey fert,

I tried that and various other combinations with the quotes and functions...still does not work. Are u sure there are no more errors? Thanks for the previous reply man.

 

Does anyone else see an error??

 

__

kvishnu_13

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.