Jump to content

Variables initialize everytime I go to a page


Go to solution Solved by ady_bavarezu89,

Recommended Posts

That is NOT what session_start()

it is not? why is user_id null (Notice: Undefined index: user_id in) when I go to b.php the second time then?

 

The first time it shows 1 as it should but from the second time it becomes undefined.

it is not? why is user_id null (Notice: Undefined index: user_id in) when I go to b.php the second time then?

 

The first time it shows 1 as it should but from the second time it becomes undefined.

I think I found my problem....On my page b.php I also had a logout option. Which means that if I press a button my session is destroyed.

 

and I did it that way:

<button class="btn btn-primary" type="submit" onclick="myFunction()"> </button>

<script>
function myFunction(){
			<?php 
                          session_destroy();

			?>
		}
</script>

So php is interpreting my php code even if it's inside a javascript function that wasn't called. That's why that guy warned me about using javascript and php!

Edited by ady_bavarezu89
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.