• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

How can I get user id from session in javascript?

javascriptphpcodeigniter


PHP Snippet 1:

<input id="userId" value="<?php $_SESSION['user_id'] ?>" style="display:none">

PHP Snippet 2:

$( document ).ready(function() {
   alert( $('#userId').val() );
   console.log('done');
});

Related Snippets

MySQL default time format UTC or GMT?

Post Form Data To phpmyadmin Database

html-php form submission after validation through JavaScript [closed]

args[max_input] woocommerce if statement confused

Log a user out of a website when they put their computer to sleep

Why does codeigniter & Linux server throws unserialize() session data error when user tries to login

add " ? " in url via htaccess RewriteRule

Assets not referencing to public folder (Laravel)

WordPress ACFNotice: get_field() - We've detected one or more calls to retrieve ACF field values before ACF has been initialized

php script to delete files older than 24 hrs, deletes all files

How to get rid of ampersand using WP Nonce URL and WP Redirect or PHP header

What will the best solution for this multiple optional filter?

Form repeater send wrong data with last element in Laravel

Xdebug can't connect back to Docker host

How to submit the custom form data in database in WordPress without plugin using ajax?

About Contact Privacy policy Terms and conditions