Jump to content

PHP Session not started but ignored if started

Go to solution Solved by vorticalbox,
50 minutes ago, Joveice said:

Hi, I'm trying to use my function but it returns null each time there is something wrong and I know it does it on this line


if (!empty($_SESSION['errormsg'])) {
	return('null');
}

Tho I know it's not empty because I have it echo the error message in the corner while working.

If I add session_start(); on the start of the function script file this error comes up (and still returns null).

line 14 is session_start();


Notice: A session had already been started - ignoring session_start() in *File* on line 14

What is this? and how do you fix this?

you're asking if errormsg is not empty then return null. Thus if it has a value it will return. take the ! away then it will return null if empty.

 

Hi, I'm trying to use my function but it returns null each time there is something wrong and I know it does it on this line

if (!empty($_SESSION['errormsg'])) {
	return('null');
}

Tho I know it's not empty because I have it echo the error message in the corner while working.

If I add session_start(); on the start of the function script file this error comes up (and still returns null).

line 14 is session_start();

Notice: A session had already been started - ignoring session_start() in *File* on line 14

What is this? and how do you fix this?

Back-end developer, electronics "hacker"

Link to post
Share on other sites

50 minutes ago, Joveice said:

Hi, I'm trying to use my function but it returns null each time there is something wrong and I know it does it on this line


if (!empty($_SESSION['errormsg'])) {
	return('null');
}

Tho I know it's not empty because I have it echo the error message in the corner while working.

If I add session_start(); on the start of the function script file this error comes up (and still returns null).

line 14 is session_start();


Notice: A session had already been started - ignoring session_start() in *File* on line 14

What is this? and how do you fix this?

you're asking if errormsg is not empty then return null. Thus if it has a value it will return. take the ! away then it will return null if empty.

 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to post
Share on other sites

21 minutes ago, vorticalbox said:

you're asking if errormsg is not empty then return null. Thus if it has a value it will return. take the ! away then it will return null if empty.

 

O snap, Thanks!

I hope I can learn more about PHP from a school one day and not just by watching youtube videos and browsing the documentation :)

Back-end developer, electronics "hacker"

Link to post
Share on other sites

35 minutes ago, Joveice said:

O snap, Thanks!

I hope I can learn more about PHP from a school one day and not just by watching youtube videos and browsing the documentation :)

YouTube and documents are vastly better than education. Here in the UK they still teach visual basic as a programming language.

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×